February 22, 2011

  

How to Change System Timezone on Linux Distros – Centos, Ubuntu, Redhat, Fedora

Post image for How to Change System Timezone on Linux Distros – Centos, Ubuntu, Redhat, Fedora

0 comments

in Linux and the Families

Sometimes, our server’s timezone is pointing to wrong timezone. How do we setup or change the timezone under Linux operating systems?

The system dates are displayed using a reference from a file in your /etc directory called localtime, if you change this your are almost done.

Generic procedure to change timezone

Change directory to /etc

# cd /etc

Create a symlink to file localtime:

# ln -sf /usr/share/zoneinfo/EST localtime

OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)

# ln -sf /usr/share/zoneinfo/EST localtime

OR if you want to set up it to WIT (Asia/Jakarta):

# ln -sf /usr/share/zoneinfo/Asia/Jakarta localtime

Please note that in above example you need to use directory structure i.e. if you want to set the timezone to Jakarta (Indonesia) which is located in the Asia directory you will then have to setup using as above.

Use date command to verify that your timezone is changed:

$ date

Output:

Tue Feb 22 09:55:37 WIT 2011

Use of environment variable

You can use TZ environment variable to display date and time according to your timezone:

$ export TZ=Asia/Jakarta
$ date

Sample Output:

Tue Feb 22 09:55:37 WIT 2011

Maybe you also want to read:

  1. Create Mass Users And Change Passwords With A Bash Script What a day! I have to install a new server...
  2. How to Change User’s Shell Environment in FreeBSD In FreeBSD, user’s default shell environment is either sh or...


Previous post:

Next post: