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.
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:
First, back up your current time zone:
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:
Now you can check the current system time using the date utility:
If you have rdate installed, you can synchronize time with the network:
It remains only to synchronize your hardware clock with the new settings, to do this, run the command:
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:
This setting is saved only for the current shell session.
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:
On CentOS and Fedora:
In Slackware or FreeBSD:
In Ubuntu:
dpkg-reconfigure tzdata
In most cases, you will see a similar dialog box:
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 |
As we see, in 2020, in Ukraine, two time transitions are planned: March and October.
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:
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:
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
LINUX operating system
Terms: LINUX operating system