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?
110 Answers
Use timedatectl
sudo timedatectl set-timezone <timeszone>Examples:
Timezone as EST
sudo timedatectl set-timezone ESTTimezone as UTC
sudo timedatectl set-timezone UTCListing all valid Timezones
timedatectl list-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:
dpkg-reconfigure tzdataA menu based tool should be started that allows you to change the timezone.
The following also work. For GMT:
ln -sf /usr/share/zoneinfo/GMT /etc/localtimeFor EST:
ln -sf /usr/share/zoneinfo/EST /etc/localtime 4 The most ease way especially to a server is to list timezones:
timedatectl list-timezonesAnd choose yours, for example:
timedatectl set-timezone Europe/AthensThats it! , :-)
Edit the timezone file at the /etc folder as:
Etc/GMTYou can use the next format:
Region "/" City Example of /etc/timezone:
Europe/Athensor
Europe/Paris
Europe/LondonYou may experiment with the: dpkg-reconfigure tzdataand 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. run TZ=Pacific/Kiritimati date to see what time it is on Christmas Island, or export TZ=Pacific/Kiritimati to have the setting last for a shell session.
cp -p /usr/share/zoneinfo/US/Pacific /etc/localtimeI 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.
1I use the following script to ask the user which timezone to set, and then confirm it has indeed been set:
#!/bin/sh
sudo timedatectl set-timezone $(tzselect)
echo
echo timedatectl says:
timedatectlI 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 sucp /usr/share/zoneinfo/Asia/Singapore /etc/localtime- Restart the server
- Done