You get a bonus - 1 coin for daily activity. Now you have 1 coin

Configuring Linux Time Zone

Lecture



inux stores and processes system time in a special Unix format — the number of seconds past from midnight on January 1, 1970 GMT. This date is considered the beginning of the Unix era. The time zone is used to convert GMT to regional time. By default, the system can set the wrong time zone, this will lead to confusion in the event logs, and other difficulties. But all this is easy to fix. In this article, you will learn several ways to configure the time zone in Linux.

Setting the time zone in localtime

The most popular and supported way to set the time zone in most distributions is through a symbolic link to the original time zone file in / etc / localtime. The list of available time zones can be viewed with the command:

$ ls / usr / share / zoneinfo /

First, back up your current time zone:

$ cp / etc / localtime /etc/localtime.bak

To create a symbolic link, use the ln -sf command. The zone file must be selected from those available in the system. For example, my time zone is Ukraine, Kiev, the following command will be used for installation:

ln -sf / usr / share / zoneinfo / Europe / Kiev / etc / locatime

Now you can check the current system time using the date utility:

$ date

If you have rdate installed, you can synchronize time with the network:

$ / usr / bin / rdate -s time-a.nist.gov

It remains only to synchronize your hardware clock with the new settings, to do this, run the command:

$ / sbin / hwclock - systohc

If you want to change the time zone only for a specific program or script, simply change the TZ environment variable for it, for example:

$ export TZ = Europe / Kyiv

This setting is saved only for the current shell session.

Other console utilities

If you do not want to use the method described above, you can use special utilities. In different distributions they are called differently.

On RedHalt Linux:

$ redhat-config-date

On CentOS and Fedora:

$ system-config-date

In Slackware or FreeBSD:

$ tzselect

In Ubuntu:

$ dpkg-reconfigure tzdata
$ tzconfig

dpkg-reconfigure tzdata

In most cases, you will see a similar dialog box:

  Configuring Linux Time Zone

Check the time:

  date --date = '20201101'
 Tue Nov 1 00:00:00 EET 2020 

Now everything is fine, the system will switch to the EET time zone. To be sure, you can view the rules for the transfer of time for Kiev

  zdump -v Europe / Kiev |  grep 2020

Europe / Kiev Sun Mar 29 00:59:59 2020 UT = Sun Mar 29 02:59:59 2020 EET isdst = 0 gmtoff = 7200
Europe / Kiev Sun Mar 29 01:00:00 2020 UT = Sun Mar 29 04:00:00 2020 EEST isdst = 1 gmtoff = 10800
Europe / Kiev Sun Oct 25 00:59:59 2020 UT = Sun Oct 25 03:59:59 2020 EEST isdst = 1 gmtoff = 10800
Europe / Kiev Sun Oct 25 01:00:00 2020 UT = Sun Oct 25 03:00:00 2020 EET isdst = 0 gmtoff = 7200

As we see, in 2020, in Ukraine, two time transitions are planned: March and October.

Option number 2. Manual w

Setting the time zone in the GUI

In Ubuntu, the time zone can be configured in the system settings. To do this, select the date and time, and select your location on the map, or type the search names in the input field:

  Configuring Linux Time Zone

In KDE, you can also set the time zone in the system settings. Launch systemsettings, open the localization item, go to the date and time section, and then open the time zone tab:

  Configuring Linux Time Zone

It remains to select the time zone in the list and click the apply button.

Synchronize exact time

ntpdate -s time.nist.gov


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

LINUX operating system

Terms: LINUX operating system