Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 修改系統日期時間指令:date 設定與 hwclock 寫入 BIOS

編輯:Linux 教學

使用 date 修改系統時間,再用 hwclock 同步至硬體時鐘(CMOS),確保重開機不失效。

常用格式

需求指令
僅修改日期date -s "2024-10-02"
僅修改時間date -s "10:08:00"
同時修改日期時間date -s "2024-10-02 04:53:00"

注意:日期時間中間有空格,必須用雙引號括起。

寫入硬體時鐘

hwclock -w

或 clock -w (舊版相容)。

驗證

date
hwclock -r

時區設定

timedatectl set-timezone Asia/Taipei
# 或手動
ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime

NTP 自動同步(建議)

systemctl enable --now chronyd
# 或 ntpd
systemctl enable --now ntpd

手動改時間僅適用單機臨時測試,生產環境請啟用 NTP/Chrony 自動同步。

Copyright © Windows教程網 All Rights Reserved