How To Configure Time And Date In Linux

time date commands in Linux

In today's post, We will see how can configure time and date in Linux system. There are basically two types of clock presents in all modern systems. (i) Real-Time Clock means hardware based clock e.g CMOS which is working even your system is shutdown/ power off (ii) System Software Clock means software based clock which is managed by kernel itself. kernel fetch its initial value from the RTC(real time clock) It only works when the system is turn on. Basically we have an inbuilt package utility name 'date' which we use to display date & time and manage it.

To manage time and date in Linux , we have two utilities available (i) date which is available in all old and new Unix-Like system (ii) timedatectl utility is available in modern Linux OS and it is a part systemd system and service manager. In this post we will use both these utilities to display , manage , modify system date and time in Linux. lets start...

'timedatectl' commands in Linux

timedatectl :  This command will display the current time and date along with detailed information.

timedatectl command in linuxx


timedatectl set-time YYYY-MM-DD : Set the current date in your Linux system.

Where YYYY = Year , MM = Month, DD = Date .


set time and date command in Linux

timedatectl set-time HH:MM:SS : Set the current time in your Linux system.

Where HH = Hours, MM = Minute, SS = Seconds


set time in Linux system

timedatectl set-local-rtc boolean : To maintain your system clock in local time. By default it is set to UTC

Where boolean = yes / no  

set time to local configure in Linux

Please read the warning message in the last of the above pic.

timedatectl list-timezones : To list the all available time-zones .


set the time zone in Linux timedatectl

timedatectl set-timezone zone : To set the time zone for your system. 

where zone = your time zone name


set time zone in Linux

timedatectl set-ntp boolean_value :  To enable sync the time with NTP server.

where boolean = yes / no


NTP sync enable commands

'date' Commands in Redhat Linux

date : This command simply show the current time and date.


date commands examples

date --utc : By default 'date' command show the local time. To check universal time coordinator use 

--utc option along with 'date' command 

date commands examples


date +"format" : This is the universal way to show the date in desire format.

replace "format" with desire date format.


date commands examples

All available formats are below :


date commands examples in Linux


date +"%Y-%m-%d %H:%M" : Shows the current date and time in given format .

date command examples in Linux


date +%F -s YYYY-MM-DD : To set the date according to given format.

Where YYYY-MM-DD is the actual date which you want to set in system. %F = Full , -s = set


date commands examples in Linux

date +%T --set HH:MM:SS : To set the time in system as given format. If you want to set the clock 

UTC add --utc option.

Where HH:MM:SS  is actual time and --set to set the time in system , --utc to set clock to UTC.


date commands examples advance

Please share the post with your friends 😀


Post a Comment