Americas

  • United States
sandra_henrystocker
Unix Dweeb

Timedatectl can control your Linux time and time zone

How-To
Dec 17, 20213 mins
Linux

Multiple-exposure shot of a clock and calendar pages. [time / past / future / history / what's next]
Credit: STILLFX / Getty Images

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

To display the current settings, use the command by itself—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	    

The fields shown include the local time, universal time (the same around the globe), RTC (the real-time clock, usually an integrated circuit), and the time zone (America/New York” is the Eastern US time zone). NTP is network time protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In this case, the RTC it is not set to the local time zone.

Time and date changes are seldom needed since your system generally manages this from the time of installation using NTP. If you move or take your laptop on vacation with you, however, you might want to make some changes to accommodate your new location.

To change your settings, you need to use sudo.

$ timedatectl set-timezone America/New_York	

You can change the time zone using sudo, but not the date or the time if your system clock is synchronized.

If you want to list the time zones, you can use the list-timezones option. There are 339 of them, so I prefer passing the command’s 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-Up

You can look into additional timedatectl command options by asking for help like this:

$ timedatectl -h command.
sandra_henrystocker
Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author