I have a virtual machine that is set to PST that a couple of colleagues have in different time-zones.
If I wanted to change the time-zone to EST and GMT, what do I need to do?
I have a virtual machine that is set to PST that a couple of colleagues have in different time-zones.
If I wanted to change the time-zone to EST and GMT, what do I need to do?
Use
timedatectl
Examples:
Timezone as EST
Timezone as UTC
Listing all valid Timezones
This command is perfect for automation scripts since it doesn't require any user interaction while compared to the other given answer based on
dpkg-reconfigure tzdata
.As root you have to execute:
A menu based tool should be started that allows you to change the timezone.
The following also work. For GMT:
For EST:
The most ease way especially to a server is to list timezones:
And choose yours, for example:
Thats it! , :-)
Edit the
timezone
file at the/etc
folder as:You can use the next format:
Example of
/etc/timezone
:or
You may experiment with the:
dpkg-reconfigure tzdata
and check cat the timezone file.You must reboot or start again a service (not the ntp service). I do not know which one. If somebody knows please share with us. (Tested on Ubuntu 15.10 the change is taken into account instantly)
To run one program with a different time zone setting, set the
TZ
environment variable, e.g. runTZ=Pacific/Kiritimati date
to see what time it is on Christmas Island, orexport TZ=Pacific/Kiritimati
to have the setting last for a shell session.I recommend AGAINST linking like mentioned by others. If some script accidentally over writes your
/etc/localtime
file, then it overwrites your Pacific timezone file... and it's a bit of a pain to replace it.Just copy the Pacific file over the localtime file with the command above.
I use the following script to ask the user which timezone to set, and then confirm it has indeed been set:
I call it
tz-set
.As root you have to execute:
ln -fs /usr/share/zoneinfo/Europe/Warsaw /etc/localtime && dpkg-reconfigure --frontend noninteractive tzdata
This worked for me on GCP Ubuntu 14 via SSH
sudo su
cp /usr/share/zoneinfo/Asia/Singapore /etc/localtime