Changing The Time Zone In Linux (Command Line)

There are several different ways to manage time in Linux. This quick tip will show you how to quickly change the local time to the correct time zone for the server. In this Linux tip I’ll show you how to change the localtime to your (or a) current time zone.

Location of the local time file
Linux looks at /etc/localtime to determine the current time of your machine. This can either be a symbolic link to the correct time zone or a direct copy of the time zone file.

Timezone files are located in /usr/share/zoninfo/
For this tip we will assume your server is located in America and will be under the Chicago CST zone.

I change the Linux time zone by copying or making a symbolic link to from /usr/share/zoneinfo/America/Chicago to /etc/localtime

Two methods to do this

1) cp /usr/share/zoneinfo/America/Chicago /etc/localtime
2) ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime

Type w to change the new time and you’re done!

Hands-On Linux Training

8 thoughts on “Changing The Time Zone In Linux (Command Line)

  1. Why is there not a reasonable way to change the time settings? I keep getting a permission denied error and ive tried to sudo, but alas no. This is ridiculous. The Internet runs on linux, but god forbid if you change timezones! As someone who travels a lot, this is an exceedingly tedious dance to have to do every time I just want to see the correct time!

  2. This blog gives a good tip for setting the system time reference, if it was not done properly at setup time.
    For Joe:
    Linux is a multiuser system. Different users can be and use different timezone settings.
    The TZ environment variable is designed to do the job.
    eg: TZ=UTC date #to display the current time/date using the UTC timezone.
    or: export TZ=PDT; date
    The TZ variable can set for more permanent use in the user profile.
    It is not a good idea to mess about with the system time and and timezone setting except during system setup by the administrator, because changing these will likely affect file timestamps, system time intervals, and other users’ time reference.

  3. To preserve links and avoid confusion inside of a chroot cage, the syntax should be:

    * ln -sf ..//usr/share/zoneinfo/America/Chicago /etc/localtime

  4. Hello. When installing the server I set local time to UTC (GMT) as you suggested:
    # cp /usr/share/zoneinfo/UTC /etc/localtime;
    When maintaining the server
    # apt-get update && apt-get upgrade;
    server local time changed (to local summer time) and I had to repeat the trick.
    How do I keep the server (Debian wheezy) on UTC? Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *