Change Time Zone for RHEL, Fedora, Ubuntu and Debian Linux using timedatectl command.
This post shows how to query and set the time linux zone in the command line by timedatectl on most Linux distributions. The command line tool timedatectl use to check and modify time zone setting.
Run the query using timedatectl
without additional arguments:
$ timedatectl
Local time: Wed 2021-02-17 17:04:29 GMT
Universal time: Wed 2021-02-17 17:04:29 UTC
RTC time: Wed 2021-02-17 16:57:58
Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Now set the time zone to another zone:
$ sudo timedatectl set-timezone Europe/Zurich
To query the changed time zone setting:
$ timedatectl
Local time: Wed 2021-02-17 18:05:58 GMT
Universal time: Wed 2021-02-17 17:05:58 UTC
RTC time: Wed 2021-02-17 16:59:27
Time zone: Europe/Zurich (CET, +0100)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
The available time zones showing with the following command:
$ timedatectl list-timezones
Since there are many time zones, the query becomes very long; the query can be narrowed down with grep:
$ timedatectl list-timezones | grep Europe
The next relevant post might also be helpful. This post Set system locale on Linux shows how to query and set the time zone in the command line.
The timedatectl command allows you to query and change the configuration of the system clock and its settings. You can use this command to set or change the current date, time, and timezone. Or enable automatic system clock synchronization with a remote NTP server.
Here you walk through the ways you can manage time on your Linux system by setting the date. The time, timezone, and synchronize time with NTP from the terminal using the new timedatectl command.
It is always a good practice to maintain the correct time on your Linux server or system and it can have the following advantages:
- maintain a timely operation of system tasks since most tasks in Linux are controlled by time.
- the correct time for logging events and other information on the system and many more.