Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

there has been a few questions about this topic and i know the answer this could help others and maybe someone could help me out if what i want to do is possible

i want to chainge the timezone of the system clock from the terminal this caan be done with

tzselect "which opens a gui in terminal" or sudo cp /usr/share/zoneinfo/Europe/London /etc/localtime "which will set to gmt"

but is there a way to set time zone with just the offset ie.-1 or +5 etc?

i need to do this as im writing an aplication to adjust timeoffset or report logs and the only info i have is the user ip which i can use a webapp to locates location of ip but then i need to set offset which would be easy IF i could just get offset of location but if i need to find zone and city it would be a rreal pain if anyone knows the answer to how to set system clock with +/-hour would be great its hard to find info with ubuntu forums being down

share|improve this question
Please help us to pick up the accepted answer. I think @Mitch's answer is the best – Nam G VU Oct 10 '14 at 5:27

To change time zone from terminal, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo dpkg-reconfigure tzdata

Once open, just follow the screens to change the time zone.

share|improve this answer
This is the easiest, most painless method. – Thomas Ward Jul 22 '13 at 22:19
this wont work as i need to altr timezone from a program without user input i need a command i can feed into terminal not gui solution thanks for reply – user2155009 Jul 23 '13 at 11:45
@user2155009 very easy non-GUI purely Terminal-based solution is in Collin Anderson's answer. I don't understand why anyone would give a GUI answer to a Terminal question. If we wanted to use a GUI, we would have used a GUI anyway, not launch Terminal from GUI, then launch a GUI from Terminal... – ADTC Jan 9 at 6:00

You can also use the new timedatectl to set the time in 14.04.

sudo timedatectl set-timezone America/New_York
share|improve this answer
How do you install it on ubuntu? – Lex Podgorny May 25 '15 at 4:09
It's installed by default on 14.04. – Collin Anderson Jun 30 '15 at 19:24
To see all available options, you can run ls -R --group-directories-first /usr/share/zoneinfo. (Be careful not to modify or erase any file here.) More info about posix and right prefixes is here. – ADTC Jan 9 at 5:57
This works! ... – Dan Nissenbaum Feb 8 at 19:10

You can use the GMT±x files in /usr/share/zoneinfo/Etc.

sudo ln -fs /usr/share/zoneinfo/Etc/GMT$offset /etc/localtime
share|improve this answer
thanks allot for reply im getting an error ln: failed to create symbolic link `/etc/localtime': File exists oboiusly im not sure what im doing do you know of good tutorial for this or even some key words i can google thanks am i using command correctly? im using sudo ln /usr/share/zoneinfo/Etc/GMT$+1 /etc/localtime to set clock to +1gmt – user2155009 Jul 22 '13 at 21:18
minitech forgot the force flag I guess so -> sudo ln -sf .... – Tele Oct 28 '13 at 17:11
This will kinda work, but won't update the tz name in /etc/timezone. – poolie Jul 17 at 14:51

I realize this thread is a bit dated, but I was looking for a better solution because I needed to automatically set the timezone in a VM after a user downloads it from our website and deploys it. Here's what I ended up with:

echo "Setting TimeZone..."
export tz=`wget -qO - | sed -n -e 's/.*<TimeZone>\(.*\)<\/TimeZone>.*/\1/p'` &&  timedatectl set-timezone $tz
export tz=`timedatectl status| grep Timezone | awk '{print $2}'`
echo "TimeZone set to $tz"

This will query from the server once it is started on the new network (my script checks for connectivity first course) and then set the server's timezone based on the response.

The "wget -q0 -" tells wget to output only the results to stdout which is then piped to the $tz variable.

Hope it helps someone!

share|improve this answer

TL;DR /etc/localtime is a symbolic link that points to a file in /usr/share/zoneinfo/Continent/City. By altering where it points you can alter your timezone.

In order to change timezone, remove the /etc/localtime and assign symbolic link to your desired city. For instance, ls -l /etc/localtime reports that this file points to /usr/share/zoneinfo/America/Denver. To change it to New York, I do

  1. sudo rm /etc/localtime
  2. sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
  3. Wait a minute for my clock to get updated

The screenshot bellow shows the steps and confirmation from timedatectl

enter image description here

share|improve this answer

The easy way to update the timezone is to use sudo dpkg-reconfigure tzdata. But this isn't so easily scripted.

If you want to set the timezone explicitly via a script (e.g. for setting up a VM), here's a recipe:

Set a variable for the timezone you want, e.g. one of


Valid values are the directories and filenames under /usr/share/zoneinfo.

Then simply

sudo cp -vf /usr/share/zoneinfo/$tz /etc/localtime
echo $tz | sudo tee /etc/timezone

Note that both /etc/localtime and /etc/timezone must be consistent.

Probably now reboot to get all your services updated too (e.g. cron).

share|improve this answer

You cannot do this unless you select the time zone file you want to correspond to each time zone offset.

Some answers suggested using the files in /usr/share/zoneinfo/Etc, but the problem with these is that they are DST agnostic.

So unless you pick some time zone configuration to match each offset, or you don't care about DST, there is no way to do it generically.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.