It is very important that your installed operating system has the correct date and time settings because many programs that run in the background (cronjobs) are executed at certain times and also log entries contain timestamps so that system events can be traced in case of an error. And of course, if you’re working on the desktop, the clock should show the correct time 🙂
In this tutorial we will show you how to set the date and time in Rocky Linux 8, AlmaLinux 8, and CentOS 8 both from the GUI and from the shell (command line).
Change Date & Time using the Terminal
The command ‘timedatectl’ allows us to set the time of the system clock. You can also use the ‘timedatectl’ command to change the date and time zone.
The following steps are involved to set the date and time by using the terminal:
Step 1. Open the terminal window using shortcut keys ‘Ctrl + Alt + t’.
Step 2. To display the already adjusted date and time on your system, type the following command:
$ timedatectl status
Step 3. To check the current Time zone of your operating system write following command:
$ timedatectl
To check all available time zone in your system, write the following command on the terminal:
$ timedatectl list-timezones
Step 4. To change the time of your operating system you can use the following command:
$ timedatectl set-time 16:19:00 $ timedatectl
The ‘timedatectl set-time’ command is used to adjust the time. The correct format is HH:MM:SS in which HH: Hours MM: Minutes SS: Seconds. You can adjust it accordingly.
Step 5. To adjust the date, write the following command in the terminal:
$ timedatectl set-time 2019-12-12 $ timedatectl
The ‘timedatectl set-time’ command is used to set the date. Format to adjust the required date is YY: MM: DD in which YY: Year MM: Month DD: Date. You can adjust the date accordingly.
Step 6. You can adjust both the date and time at once. For this purpose write the following command.
$ timedatectl set-time '2019-12-12 16:18:45' $ timedatectl
The format is available in YY-MM-DD HH:MM: SS. You can adjust the time and date as you want.
Set Date and Time using the Graphical User Interface
Step 1. Login to your system and click on ’Activities’ that is present on the left top corner of the desktop on your Desktop.
Step 2. You will see a few icons on the desktop. Click on the “Settings” icon from this window.
Step 3. Now, a window will appear on the screen. Click on the search icon that will available on the left top corner of the display screen.
Step 4. In the search bar, write “Date and time”. In response to your search action, relevant results will appear in the current window.
Step 5. Click on that option. Another screen will appear on the system. Click on Date and time as highlighted in the below-mentioned image.
Step 6. Now, an interface will appear on the system in which the “+” sign will increase the time and “-” will decrease it. You can adjust your time according to your time zone. Day and year can also be adjusted similarly by using ‘+’ and ‘-’ signs.
In the ‘month’ section, a drop-down menu is available from where you can select the desired month.
Step 7. You can adjust the time zone as well by clicking on “Time Zone” present in the current window.
In the search bar write the name of the desired city in your region. The time zone will be adjusted automatically after performing this action.
You can also adjust the time format to which you want to adjust it as 24-hours or AM/PM format. You can adjust it from the drop-down.
Conclusion
In this article, you have learned how to set time and date on RHEL based Linux distributions like AlmaLinux, CentOS, and Rocky Linux. I hope this article would useful to you. Now, you are able to change the date and time of your Linux system. In case of any problem, you can share your problem via comments.