在 Linux 系统中,启动时间通常指的是系统启动时的日期和时间。如果你想要修改系统启动时的日期和时间,可以使用 timedatectl 或 date 命令。
✅ 一、查看当前系统时间
timedatectl
输出示例:
Local time: 2025-04-05 12:34:56
Universal time: 2025-04-05 08:34:56
UTC time: 2025-04-05 08:34:56
Time zone: UTC+8 (China Standard Time, CDT)
Last login: Sat Apr 5 08:34:56 UTC2025
✅ 二、修改系统时间(使用 timedatectl)
1. 修改系统时间(UTC 时间)
sudo timedatectl settime <UTC时间>
例如:
sudo timedatectl settime 2025-04-05 08:34:56
2. 修改系统时间(本地时间)
sudo timedatectl setlocaltime <本地时间>
例如:
sudo timedatectl setlocaltime 2025-04-05 12:34:56
✅ 三、修改系统时区
如果需要修改系统时区,可以使用:
sudo timedatectl settime zone <时区>
例如:
sudo timedatectl settime zone UTC+8
或者使用 timedatectl 的 settime zone 命令:
sudo timedatectl settime zone Asia/Shanghai
✅ 四、修改系统时间后立即生效
修改时间后,需要重启系统才能生效:
sudo reboot
✅ 五、使用 date 命令修改时间(不推荐,因为不持久)
sudo date -s "2025-04-05 12:34:56"
但该命令在系统重启后会失效,不推荐用于生产环境。
✅ 六、查看系统时间(本地时间)
date
输出示例:
Mon Apr 5 12:34:56 CST 2025
✅ 七、查看系统时间(UTC 时间)
timedatectl | grep "UTC time"
✅ 八、其他相关命令
timedatectl是最推荐的工具,它会自动同步系统时间与时区。- 如果你使用的是
systemd系统(如 Ubuntu、Debian、CentOS 等),timedatectl是标准工具。
✅ 总结
| 命令 | 功能 |
|---|---|
timedatectl |
查看和修改系统时间与时区 |
sudo timedatectl settime |
修改系统时间(UTC 或本地) |
sudo timedatectl settime zone |
修改系统时区 |
sudo date -s |
修改系统时间(不持久) |
如需进一步定制时间格式或自动同步时间,请告诉我你的具体需求。


