Using the timedatectl command to control your Linux time and time zone

The timedatectl The command allows you to query and change the system clock and its settings on Linux systems.

To display the current configuration, use the command alone, with no arguments. You should see something like this:

$ timedatectl
               Local time: Thu 2021-12-16 11:12:31 EST
           Universal time: Thu 2021-12-16 16:12:31 UTC
                 RTC time: Thu 2021-12-16 16:12:31	    <; real time clock
                Time zone: America/New_York (EST, -0500)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

The fields displayed include local time, universal time (the same all over the world), RTC (the real-time clock, usually an integrated circuit), and the time zone (America / New York ”is the time zone of the East). NTP is a network time protocol for clock synchronization between computer systems over packet-switched variable latency data networks. In this case, the RTC is not configured in the local time zone.

Date and time changes are rarely necessary, as your system generally handles them from the time of installation using NTP. However, if you move or take your laptop on vacation, you may want to make a few changes to suit your new location.

To change your configuration, you must use sudo.

$ timedatectl set-timezone America/New_York	<== no change, no authentication
$ timedatectl set-timezone America/Nome
==== AUTHENTICATING FOR org.freedesktop.timedate1.set-timezone ====
Authentication is required to set the system timezone.
Authenticating as: Sandra Henry-Stocker (shs)
Password:
==== AUTHENTICATION COMPLETE ====
$ timedatectl
               Local time: Thu 2021-12-16 07:27:00 AKST
           Universal time: Thu 2021-12-16 16:27:00 UTC
                 RTC time: Thu 2021-12-16 16:27:00
                Time zone: America/Nome (AKST, -0900)
System clock synchronized: yes
              NTP service: active
             RTC in local TZ: no

You can change the time zone using sudobut not the date and time if the system clock is synchronized.

If you want to list the time zones, you can use the list of time zones option. There are 339 of them, so I prefer to pass the command output to the column command:

$ timedatectl list-timezones | wc -l
339

$ timedatectl list-timezones | column
Africa/Abidjan                  America/Paramaribo              Asia/Yekaterinburg
Africa/Algiers                  America/Phoenix                 Asia/Yerevan
Africa/Bissau                   America/Port-au-Prince          Atlantic/Azores
Africa/Cairo                    America/Porto_Velho             Atlantic/Bermuda
Africa/Casablanca               America/Puerto_Rico             Atlantic/Canary
Africa/Ceuta                    America/Punta_Arenas            Atlantic/Cape_Verde
Africa/El_Aaiun                 America/Rainy_River             Atlantic/Faroe
Africa/Johannesburg             America/Rankin_Inlet            Atlantic/Madeira
Africa/Juba                     America/Recife                  Atlantic/Reykjavik
Africa/Khartoum                 America/Regina                  Atlantic/South_Georgia
Africa/Lagos                    America/Resolute                Atlantic/Stanley
Africa/Maputo                   America/Rio_Branco              Australia/Adelaide
Africa/Monrovia                 America/Santarem                Australia/Brisbane
Africa/Nairobi                  America/Santiago                Australia/Broken_Hill
Africa/Ndjamena                 America/Santo_Domingo           Australia/Darwin
…                               …                               …

Wrap

You can search in additional timedatectl command options asking for help like this:

$ timedatectl -h command.

Join Network World communities at Facebook Y LinkedIn to comment on the most important topics.

Copyright © 2021 IDG Communications, Inc.

Leave a Comment