What systemd command allows you to view and change the time date and time zone

Readers like you help support MUO. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.

Keeping software on your device up to date is an important part of having a robust and secure system, but even more important is having an up-to-date time and date.

Accurate time and date on a system not only tells you the correct time but also allows you to execute automated tasks as expected and connect to services over the internet seamlessly.

This guide will show you how to review, adjust, and configure the time and date on Linux from the command line using the timedatectl command.

How Time Is Managed on Linux

In order to keep accurate time, Linux uses two different kinds of clocks :

  • A real-time clock (RTC) or hardware clock integrated into your computer's circuit board which runs independently of the operating system. The clock still runs even when your operating system is shut down, rebooting, or hibernating.
  • A system clock, also popularly known as a software clock. Maintained by the Linux kernel, the system clock depends on the real-time clock to get its initial time when your Linux OS is booting up.

By default, your system time is kept in the Universal Coordinated Time (UTC) format. Your Linux system then converts the UTC time to the correct local time based on your region or time zone. The local time is what's displayed on the desktop.

Listing Time and Date Information

One of the most important tasks you should be able to carry out when it comes to configuring the time on Linux is to be able to list and review the current time on your system.

To display time and other configuration parameters, simply run the timedatectl command without any parameters as follows:

 timedatectl 

timedatectl command output on Linux

The command displays the system's local time, the UTC time, and the real-time clock. The time zone and other important time-related parameters are also listed in the output.

How to Adjust the Time on Linux

To set or change the time, use the timedatectl command together with the set-time subcommand.

 sudo timedatectl set-time hh:mm:ss 

Note: You need to have elevated privileges to adjust the time or date.

In the aforementioned command, the hh stands for hours, mm for minutes, and ss for seconds. The time you specify should be in the 24-hour format.

For example, to set the time to 12 o'clock midnight, run the following command:

 sudo timedatectl set-time 00:00:00 

The command updates both the real-time clock and the system or software clock. However, you will fail to change the time or date if the Network Time Protocol (NTP) is enabled on your system.

How to Enable/Disable NTP

The Network Time Protocol helps you in making sure that your time is synchronized with a remote server based on your time zone or region.

To disable NTP on Linux, run the following command:

 sudo timedatectl set-ntp false 

To reactivate or enable NTP, simply run:

 sudo timedatectl set-ntp true 

Once enabled, the system will automatically adjust and synchronize the time with the configured server time.

Note: The set-ntp subcommand will not work if your system doesn't support NTP.

How to Set the Date on Linux

To change the date on your computer, you can run the timedatectl command with the set-time subcommand in the following format:

 sudo timedatectl set-time YYYY-MM-DD 

...where YYYY is the year, MM is the month, and DD is the day.

For example, to change the date to January 1, 2000, issue the following command:

 sudo timedatectl set-time "2000-01-01 23:00:01" 

Note that we've also specified the time because when you only specify the date, timedatectl will automatically set the time to 00:00 i.e. 12 midnight.

Changing Your Time Zone

Before you can proceed and change the time zone on your PC, it is important that you know how to list or view available time zones.

 timedatectl list-timezones 

output of listing timezones on linux

Use the F key on your keyboard to scroll forward and the B key to scroll backward through the listed timezones. Alternatively, you can use the arrow keys for scrolling.

Once you identify your time zone, you can, for example, switch to the Africa/Blantyre time zone using the following command:

 timedatectl set-timezone Africa/Blantyre 

Getting Command-Line Help

To learn more about timedatectl, issue the following command:

 timedatectl help 

For more comprehensive coverage of the command, you can check out its man pages by running:

 sudo timedatectl set-time hh:mm:ss 
0

Related: Ways to Get Command-Line Help on Linux

Alternative Time Clock Utilities on Linux

This guide has shown you how to configure the time and date on Linux using the timedatectl utility, a powerful and modern clock adjustment that comes as a part of the systemd service. Other traditional clock configuration utilities on Linux are the hwclock and date commands.

What is the systemd command used to change the time and date?

With systemd based Linux system you need to use the timedatectl command to set or view the current date and time.

Which command is used to change the time zone for a server?

Using the timedatectl command is the most recommended method for changing the current timezone. However, if we don't have the timedatectl command available on our current system, we can create a symlink or change it through the GUI.

How to change timezone in Linux using date command?

To do this:.
Identify the correct time zone file in /usr/share/zoneinfo..
Remove the previous symbolic link from /etc/localtime..
Create a symbolic link from the correct time zone file to /etc/localtime..
Verify the change by running the date command from the terminal..

What is the command for viewing date and time in the terminal?

To display current date and time under Linux operating system using command prompt use the date command or timedatectl command. These commands can also display the current time / date in the given FORMAT. We can set the system date and time as root user too.