Source From Here
Preface
How can I set the system date and time from the command prompt (bash shell)? I don't have GUI installed and I am login over ssh session. How can I set date under Linux operating systems? Use the date command to display the current date and time or set the system date / time over ssh session. You can also run the date command from X terminal as root user.
This is useful if the Linux server time and/or date is wrong, and you need to set it to new values from the shell prompt.
Linux Display Current Data and Time
Just type the date command:
Linux Display The Hardware Clock (RTC)
Type the following hwclock command to read the Hardware Clock and display the time on screen:
Linux Set Date Command Example
Use the following syntax to set new data and time:
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
You can also simplify format using following syntax:
To set time use the following syntax:
Use %p locale's equivalent of either AM or PM, enter:
How do I set the Hardware Clock to the current System Time? Use the following syntax:
A note about systemd based Linux system
With systemd based system you need to use the timedatectl command to set or view the current date and time. Most modern distro such as RHEL/CentOS v.7.x+, Fedora Linux, Debian, Ubuntu, Arch Linux and other systemd based system need to the timedatectl utility. Please note that the above command should work on modern system too.
timedatectl: Display the current date and time
How do I change the current date using the timedatectl command?
To change the current date, type the following command as root user:
For example set the current date to 2015-12-01 (1st, Dec, 2015):
To change both the date and time, use the following syntax:
Where,
For example, set the date ’23rd Nov 2015′ and time to ‘8:10:40 am’, enter:
How do I set the current time only?
The syntax is:
For example:
How do I set the time zone using timedatectl command?
To see list all available time zones, enter:
To set the time zone to ‘Asia/Taipei’, enter:
How do I synchronizing the system clock with a remote server using NTP?
Simply type the following command:
Supplement
* nixCraft - How To Change Timezone on a CentOS 6 and 7
* You can also set new timzone using this mini-howto.
* Man pages - hwclock(8), date(1)
* [Linux 文章收集] 系統時間日期變更的指令
* [linux][shell] 關於'date' 應該知道的事
Preface
How can I set the system date and time from the command prompt (bash shell)? I don't have GUI installed and I am login over ssh session. How can I set date under Linux operating systems? Use the date command to display the current date and time or set the system date / time over ssh session. You can also run the date command from X terminal as root user.
This is useful if the Linux server time and/or date is wrong, and you need to set it to new values from the shell prompt.
Linux Display Current Data and Time
Just type the date command:
Linux Display The Hardware Clock (RTC)
Type the following hwclock command to read the Hardware Clock and display the time on screen:
Linux Set Date Command Example
Use the following syntax to set new data and time:
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
You can also simplify format using following syntax:
To set time use the following syntax:
Use %p locale's equivalent of either AM or PM, enter:
How do I set the Hardware Clock to the current System Time? Use the following syntax:
A note about systemd based Linux system
With systemd based system you need to use the timedatectl command to set or view the current date and time. Most modern distro such as RHEL/CentOS v.7.x+, Fedora Linux, Debian, Ubuntu, Arch Linux and other systemd based system need to the timedatectl utility. Please note that the above command should work on modern system too.
timedatectl: Display the current date and time
How do I change the current date using the timedatectl command?
To change the current date, type the following command as root user:
For example set the current date to 2015-12-01 (1st, Dec, 2015):
To change both the date and time, use the following syntax:
Where,
For example, set the date ’23rd Nov 2015′ and time to ‘8:10:40 am’, enter:
How do I set the current time only?
The syntax is:
For example:
How do I set the time zone using timedatectl command?
To see list all available time zones, enter:
To set the time zone to ‘Asia/Taipei’, enter:
How do I synchronizing the system clock with a remote server using NTP?
Simply type the following command:
Supplement
* nixCraft - How To Change Timezone on a CentOS 6 and 7
* You can also set new timzone using this mini-howto.
* Man pages - hwclock(8), date(1)
* [Linux 文章收集] 系統時間日期變更的指令
* [linux][shell] 關於'date' 應該知道的事
沒有留言:
張貼留言