To change the timezone in Linux, you can use the timedatectl command. You can use the list-timezones option to see a list of all available timezones, and then use the set-timezone option to set the desired timezone. For example, to set the timezone to America/New_York, you would run the command timedatectl set-timezone America/New_York. You can also use the date command to check the current time after you’ve set the timezone.
You can also do the setup by manually editing the related OS files.
In the below example we are setting the timezone to US Eastern:
Switch to root:
$ sudo su -
Take backup of the localtime file:
# cp /etc/localtime /etc/localtime_bkp_02112020 # date
Remove the localtime file:
# cd /etc # ls -trl localtime* lrwxrwxrwx. 1 root root 25 Sep 17 00:27 localtime -> ../usr/share/zoneinfo/GMT -rw-r--r--. 1 root root 118 Nov 2 13:24 localtime_bkp_02112020 # rm localtime rm: remove symbolic link ‘localtime’? y
Create new Softlink to point to correct timezone
# ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime
# ls -trl localtime* -rw-r--r--. 1 root root 118 Nov 2 08:24 localtime_bkp_02112020 lrwxrwxrwx. 1 root root 30 Nov 2 08:25 localtime -> /usr/share/zoneinfo/US/Eastern [root@server etc]# date
Latest posts by Brijesh Gogia (see all)
- Building a Scalable and Secure AI Infrastructure in the Cloud - May 12, 2024
- Harnessing the Power of AI in the Cloud for Business Transformation - March 2, 2024
- Building a Resilient Cybersecurity Framework in the Oracle Cloud - January 16, 2024