Home AlmaLinux How to Set Date and Time in Rocky and AlmaLinux

How to Set Date and Time in Rocky and AlmaLinux

Whether you are a system administrator, network administrator, or a normal user under a Linux operating system, it is important to ensure your system is set to the correct date and time in regard to your location.

For instance, your prowess in Linux administration might take you to different time zones and locations. Under such circumstances, you might need to update your Linux system with the correct date and time values so that you are not caught off guard during important activities like project presentations.

Also, some programs that run under Linux reference the system date and time values as part of their input and output data. The misrepresentation of such values can yield logical consequences.

[ You might also like: How to Set Date, Time and Timezone in RHEL 8 ]

Rocky Linux and Alma Linux are such server-based systems whose date and time values need to be set correctly in regards to the location and timezone of the OS user. Also, the execution of these systems’ cronjobs references the set date and time.

Check Date and Time in Rocky Linux

The main command we are going to reference for both Rocky Linux and AlmaLinux is timedatectl – which shows the current date and time statuses.

$ timedatectl
Check Rocky Linux Date and Time
Check Rocky Linux Date and Time

Alternatively, you could use the following command.

$ timedatectl status
Show Settings Of System Clock and RTC
Show Settings Of System Clock and RTC

Setting Timezone in Rocky Linux

After checking on the status of the date and time via the command line, the first step is to set the time zone in regard to your location. These two Linux systems make this step easy for you so that you do not need to go to Google to determine your current time zone.

You can trace and pick your preferred timezone from the following command.

$ timedatectl list-timezones
List Timezones in Rocky Linux
List Timezones in Rocky Linux

The above command reveals a scrollable list of supported time zones. For instance, we might want to use America/Aruba time zone. The command for setting timezone is as follows:

$ sudo timedatectl set-timezone America/Aruba

Check on the time and date status to be sure the new time zone value was implemented successfully.

$ timedatectl status
Set Timezone in Rocky Linux
Set Timezone in Rocky Linux

As highlighted, the time zone change was a success.

How to Set Time in Rocky Linux

The second step is to set time on your AlmaLinux and Rocky Linux systems. Changing time and date on such systems is not as straightforward as it was with the case of changing the timezone.

We have to first consider and acknowledge the viability of the Network Time Protocol (NTP). We cannot permanently change the date or time on Linux without temporarily disabling the Chrony daemon responsible for NTP.

    
$ sudo systemctl stop chronyd

From here, we can now change the time on our system to a value of our choice. The time value should be in the format hh:mm:ss as shown.

$ sudo timedatectl set-time 00:40:00
Set Time in Rocky Linux
Set Time in Rocky Linux

We can check to see if the set time was implemented.

$ timedatectl status
Check Time in Rocky Linux
Check Time in Rocky Linux

How to Set Date in Rocky Linux

The final step is to set a date on your AlmaLinux and Rocky Linux systems. With NTP still inactive/disabled, we can set the date on our systems. The date value should adhere to the format yyyy-mm-dd as shown.

$ sudo timedatectl set-time 2021-12-14

Check to see if the set date was implemented:

$ timedatectl status
Check Date in Rocky Linux
Check Date in Rocky Linux

Start the NTP service and check on its status.

$ sudo systemctl start chronyd
Start Chronyd in Rocky Linux
Start Chronyd in Rocky Linux

As you might have noticed, changing the timezone on AlmaLinux and Rocky Linux does not require stopping the NTP service but changing date and time do. It is the main tip and trick you have to master in this tutorial.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.