Timezone setting in Linux


To totally unlock this section you need to Log-in


Login

On Ubuntu/Debian systems, to change the timezone on either of these distros, you can use this command:

$ sudo dpkg-reconfigure tzdata

Timezone setting in Linux

$ sudo dpkg-reconfigure tzdata

Current default time zone: 'Etc/GMT-6' Local time is now: Thu Jan 23 11:52:16 GMT-6 2014. Universal Time is now: Thu Jan 23 05:52:16 UTC 2014.

Now when we check it out:

$ date -u

Thu Jan 23 05:53:32 UTC 2014
$ date
Thu Jan 23 11:53:33 GMT-6 2014

Red Hat distros

If you're using a distribution such as Red Hat then your approach of copying the file would be mostly acceptable. On some distributions (for example, CentOS or Red Hat distros), the timezone is controlled by /etc/localtime file. First, list all available timezones:

$ ls /usr/share/zoneinfo/

Delete the current localtime file under /etc/ directory:

# cd /etc
# rm localtime

For example, link the Pacific file from the US directory (under /usr/share/zoneinfo/US) to the /etc/localtime directory as shown below.

# cd /etc
# ln -s /usr/share/zoneinfo/US/Pacific localtime

Now the timezone on your Linux system is changed to US Pacific time as shown below.

# date
Mon Sep 17 23:10:14 PDT 2010