How to change the time zone in Linux

To set the timezone in Linux, update /etc/localtime with the appropriate timezone file from /usr/share/zoneinfo. File related to time zone is just a link, so it’s safe to remove them and change it with some other. In this case, we will rename an old link just to save a info where were it pointed before the change. Of course, you can remove it with the ‘rm’ command.

# Rename old localtime link, to save info where it was pointed out before change
mv /etc/localtime /etc/localtime_backup_$(date +%Y%m%d%H%M)

In this example, we will change timezone to PDT (mostly used in the USA)…but…actually we will change the time zone to America/Los_Angeles because LA is located in PDT timezone (well OK, you will need to google-it little bit).

# Create a new link. After this change, you will get new time immediatly.
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Now you can check with ‘date’ command, is new time applied.