Categories: How-To

Linux time zone (local time) [Basic Guide]

Configuring Time Zone Zones

Time zone information is generally required during the installation of Linux when the environment is Desktop. Rarely does the user exchange this information later.

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

Choose the zone in /usr/share/zoneinfo

The /usr/share/zoneinfo directory contains the configuration information for the time zone 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 in the /usr/share/zoneinfo directory to find subdirectories containing macro regions of the world or countries with several time zones.

$ ls -l /usr/share/zoneinfo/ 
drwxr-xr-x. 2 root root 4096 Aug 20 2018 Africa
drwxr-xr-x. You are root root 8192 Aug 20 2018 America
drwxr-xr-x. 2 root root 187 Aug 20 2018 Antarctica
drwxr-xr-x. 2 root root 26 Aug 20 2018 Arctic
drwxr-xr-x. 2 root root 4096 Aug 20 2018 Asia
drwxr-xr-x. 2 root root 196 Aug 20 2018 Atlantic
drwxr-xr-x. 2 root root 4096 Aug 20 2018 Australia
drwxr-xr-x. 2 root root 09 Aug 20 2018 Brazil
drwxr-xr-x. 2 root root 136 Aug 20 2018 Canada (...)

And inside each directory are the time zone configuration files:

$ ls -l /usr/share/ZoneInfoBrazil/ 
-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 this is done, the watch will automatically start complying with the timezone chosen for all users.

Learn much more about Linux in our online course. You can register 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

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Share
Published by
Uirá Endy Ribeiro

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.