Saturday, May 9, 2015

Date and Time in CentOS / RHEL 7



timedatectl

To display the current date and time, you can use timedatectl or as other Linux and Unix systems use the standard date command: 
$ date
$ timedatectl
To change the current date, simply enter the following command as root: 
# timedatectl set-time 2013-06-02
To synchronize the system time with an NTP server:
# timedatectl set-ntp true

date command 

As I mentioned before, date command also works in CentOS / RHEL:
$ date +"%m-%d-%Y %H:%M"
To change the current time:
# date +%T --set 13:19:00

hwclock

hwclock is another tool which shows and sets the motherboard time and date:
# hwclock