Linux timezone

From Petr Sladek

Jump to: navigation, search

How to change a timezone settings in a Linux system from a command line or console?


Check your current timezone

Check the timezone your computer is currently using by executing `date` from the command line.

slady@sladek:~$ date
Mon Apr 22 13:46:37 CEST 2013

You'll see something like Mon Apr 22 13:46:37 CEST 2013, in this case CEST is the current timezone.

Select your timezone

Check your new timezone by executing `tzselect` from the command line.

slady@sladek:~$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.

Choose the most appropriate region, if you live in Canada or the US, then this continent is called the "America".

Locate the timezone file

Change to the directory /usr/share/zoneinfo here you will find a list of time zone regions with the timezone files you are looking for.

slady@sladek:~$ cd /usr/share/zoneinfo/
slady@sladek:~$ ls
Africa      Chile    Factory    Iceland      MET      Portugal    Turkey
America     CST6CDT  GB         Indian       Mexico   posix       UCT
Antarctica  Cuba     GB-Eire    Iran         Mideast  posixrules  Universal
Arctic      EET      GMT  MST      PRC         US
Asia        Egypt    GMT0       Israel       MST7MDT  PST8PDT     UTC
Atlantic    Eire     GMT-0      Jamaica      Navajo   right       WET
Australia   EST      GMT+0      Japan        NZ       ROC         W-SU
Brazil      EST5EDT  Greenwich  Kwajalein    NZ-CHAT  ROK
Canada      Etc      Hongkong   Libya        Pacific  Singapore   Zulu
CET         Europe   HST        localtime    Poland   SystemV

Choose your timezone file, for instance America/Los_Angeles.

Backup your original timezone file

If you wish, backup the previous timezone configuration by copying it to a different location.

You have to be root to do this:

root@sladek:~# mv /etc/localtime  /etc/localtime-original

Or in Ubuntu, use sudo:

slady@sladek:~$ sudo mv /etc/localtime  /etc/localtime-original

Headline text

Change your timezone configuration file by creating a symbolic link.

You have to be root to do this:

root@sladek:~# ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime

Or in Ubuntu, use sudo:

slady@sladek:~$ sudo ln -sf /usr/share/zoneinfo/Africa/Kinshasa /etc/localtime

Of course, here you should use your current location.

Update current time

If you have the utility rdate, update the current system time by executing

/usr/bin/rdate -s

Set the hardware clock by executing:

/sbin/hwclock --systohc


  • On mobile phones and other small devices that run Linux, the time zone is stored differently. It is written in /etc/TZ, edit this file manually or use echo, for instance: echo GMT0BST > /etc/TZ to set the the timezone of the United Kingdom).
  • On RedHat Linux there is a utility called "Setup" that allows you to select the timezone from a list, but you must have installed the 'redhat-config-date' package of 'system-config-date' in RHEL5.
  • On Ubuntu/Kubuntu, Debian and other systems that use dpkg, you should try sudo dpkg-reconfigure tzdata. This will set up everything correctly in very few, simple steps.
  • On some systems, there is a system utility provided that will prompt for the correct timezone and make the proper changes to the system configuration, for instance Debian provides the "tzsetup" or "tzconfig" utility.


  • Some applications (such as PHP) have separate timezone settings from the system timezone files.
  • When updating a Virtual Server, rely on the hardware clock to be accurate rather than attempting to update it or use ntp. Attempts to update the hwclock or use ntp will fail, because the Virtual Server cannot modify the actual hardware clock.
Personal tools