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

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

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

Looking for more tips? Here are ten things I wish I knew earlier about the Linux command line

Other Quick Tutorials:


New call-to-action

10 responses to “Changing The Time Zone In Linux (Command Line)”

  1. Joe says:

    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. Anh says:

    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. Guest says:

    Great info.

  4. Luke G. says:

    Perfect! I used this to fix a time sync complaint on an OwnCloud box.

  5. Nico Kadel-Garcia says:

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

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

  6. Anubhav says:

    I did the following

    ll /etc/localtime
    ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

  7. Maja K says:

    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.

  8. Rekha Kumari Nemichand says:

    This worked. Thanks Anubhav.

  9. Prakash D says:

    This worked, Thanks!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get actionable training and tech advice

We'll email you our latest articles up to once per week.