fbpx Linux Timezone: Change with timedatectl and tzselect | Certificação Linux

Linux Timezone: Change with timedatectl, tzselect, and /etc/localtime

📅 12/06/2021 ⏱ 2 min ✍️ Uira Ribeiro
Linuxcommands
Linux Timezone: Change with timedatectl, tzselect, and /etc/localtime
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

Configuring Time Zones

Time zone information is generally required during Linux installation when the environment is Desktop. Rarely does the user change this information afterwards.

But when it comes to virtual servers and cloud-computing environments, it is usually necessary to change the time zones of these servers.

Choosing the zone in /usr/share/zoneinfo

The /usr/share/zoneinfo directory contains the configuration information for time zones. The system's local zone is determined by a symbolic link from some file in this directory to the /etc/localtime file.

It is common to find subdirectories with world macro-regions or countries with multiple time zones in the /usr/share/zoneinfo directory.

$ ls -l /usr/share/zoneinfo/drwxr-xr-x.  2 root root   4096 Aug 20  2018 Africadrwxr-xr-x.  6 root root   8192 Aug 20  2018 Americadrwxr-xr-x.  2 root root    187 Aug 20  2018 Antarcticadrwxr-xr-x.  2 root root     26 Aug 20  2018 Arcticdrwxr-xr-x.  2 root root   4096 Aug 20  2018 Asiadrwxr-xr-x.  2 root root    196 Aug 20  2018 Atlanticdrwxr-xr-x.  2 root root   4096 Aug 20  2018 Australiadrwxr-xr-x.  2 root root     59 Aug 20  2018 Brazildrwxr-xr-x.  2 root root    136 Aug 20  2018 Canada
( ... )

And within each directory there are the time zone configuration files:

$ ls -l /usr/share/zoneinfo/Brazil/-rw-r--r--. 3 root root  634 May  9  2018 Acre-rw-r--r--. 2 root root  714 May  9  2018 DeNoronha-rw-r--r--. 2 root root 2002 May  9  2018 East-rw-r--r--. 2 root root  602 May  9  2018 West

How to change the clock to local time

To change the Linux clock to local time, simply create a symbolic link from the chosen zone file to the /etc/localtime file:

$ ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime

Once done, the clock will automatically obey the chosen timezone for all users.

Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it? Share

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp