Skip to main content

Changing The Time Zone In Linux (Command Line)

Posted on July 30, 2012 by Anthony James Founder/CEOAnthony James Founder/CEO

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!


Image of Joe
4 years ago

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!

Image of Madhu Prasad
Madhu Prasad
4 years ago

good information.

Image of Anh
4 years ago

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.

Image of Guest
4 years ago

Great info.

Image of Luke G.
Luke G.
4 years ago

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

Image of Nico Kadel-Garcia
Nico Kadel-Garcia
4 years ago

To preserve links and avoid confusion inside of a chroot cage, the syntax should be:
* ln -sf ..//usr/share/zoneinfo/America/Chicago /etc/localtime

Image of Anubhav
3 years ago

I did the following
ll /etc/localtime
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

Image of Maja K
Maja K
3 years ago

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.

Image of Rekha Kumari Nemichand
Rekha Kumari Nemichand
2 years ago

This worked. Thanks Anubhav.

Image of Prakash D
Prakash D
2 years ago

This worked, Thanks!

Image of Arpit Kumar
Arpit Kumar
7 months ago

Thanks Sir… It worked .

Leave a Reply

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