YouTube Icon

Code Playground.

How to Set or Change the Time Zone in Linux

CFG

How to Set or Change the Time Zone in Linux

A time region is a geographic district that has a similar standard time. Regularly the time region is set during the establishment of the operational framework, yet it very well may be handily changed sometime in the future. 

Utilizing the right time region is basic for some, frameworks related undertakings and cycles. For instance, the cron daemon utilizes the framework's time region for executing cron occupations. The time region is additionally utilized for logs timestamps. 

This instructional exercise covers the means important to set or change the time region in Linux. 

Checking the Current Time Zone

timedatectl is an order line utility that permits you to view and change the framework's time and date. It is accessible on all cutting edge systemd-based Linux frameworks. 

To see the current time region, summon the timedatectl order with no choices or contentions: 

timedatectl
                      Local time: Tue 2019-12-03 16:30:44 UTC
                  Universal time: Tue 2019-12-03 16:30:44 UTC
                        RTC time: Tue 2019-12-03 16:30:44
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

The yield above shows that the framework's time region is set to UTC. 

The framework time region is arranged by symlinking the/and so on/localtime document to a twofold time region's identifier in the/usr/share/zoneinfo index. 

Another approach to check the time region is to see the way the symlink focuses to utilizing the ls order: 

ls -l /etc/localtime
lrwxrwxrwx 1 root root 27 Dec  3 16:29 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC

Changing the Time Zone in Linux

Before changing the time region, you'll have to discover the long name of the time region you need to utilize. The time region naming show for the most part utilizes an "Area/City" design. 

To see all accessible time regions, utilize the timedatectl order or rundown the documents in the/usr/share/zoneinfo catalog: 

timedatectl list-timezones
...
America/Montserrat
America/Nassau
America/New_York
America/Nipigon
America/Nome
America/Noronha
...

When you distinguish which time region is exact to your area, run the accompanying order as root or sudo client: 

sudo timedatectl set-timezone <your_time_zone>

 For instance, to change the framework's timezone to America/New_York you would type: 

sudo timedatectl set-timezone America/New_York

To confirm the change, summon the timedatectl order once more: 

timedatectl
                      Local time: Tue 2019-12-03 13:55:09 EST
                  Universal time: Tue 2019-12-03 18:55:09 UTC
                        RTC time: Tue 2019-12-03 18:02:16
                       Time zone: America/New_York (EST, -0500)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

Job well done! You've effectively changed your framework's time region. 

Changing the Time Zone by Creating a Symlink

On the off chance that you are running a more seasoned Linux circulation and the timedatectl utility is absent on your framework, you can change the timezone by symlinking/and so forth/localtime to the time region in the/usr/share/zoneinfo index. 

Eliminate the current symlink or document: 

sudo rm -rf /etc/localtime

Recognize the timezone you need to arrange and make a symlink : 

sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

Confirm it either by posting the/and so on/localtime document or conjuring the date order: 

date

The yield incorporates the time region, in this model that is "EST". 

Tue Dec  3 14:10:54 EST 2019

Conclusion

To change the time region in Linux frameworks utilize the sudo timedatectl set-timezone order followed by the long name of the time region you need to set. 

Don't hesitate to leave a remark in the event that you have any inquiries.




CFG