Command Line

Unix: Changing Timezone on Your Machine

My VPS resides in LA, so it is on Pacific Timezone (UTC -08:00). I want it to be on the same timezone as my current location, i.e. Singapore (UTC +08:00), since I am operating mainly in this area.

Run date in your terminal, and you will see the current time of your machine. If it is not registering the correct time (in your timezone), you might want to change the timezone of your machine.

List out the timezones available in your machine:
ls -al /usr/share/zoneinfo/

Some will appear as directories, while others are files. If you see your country as a directory, it means that your country has several timezones in different cities. The Singapore timezone appears as a file, so I can immediately do this:
ln -sf /usr/share/zoneinfo/Singapore /etc/localtime
This links the Singapore timezone to /etc/localtime, which computes your current time based on the timezone specified.

So, if I ever want it to synchronise with the timezone of LA again, I can do this:
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Leave a Reply

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