«

»

Print this Post

How to make a Linux system show the date in the local timezone

If you rent out a Linux system in the cloud, chances are when you run the date command, the time will be shown in UTC. Not only is that very disconcerting, it is downright useless. In the rare cases where there is a whole bunch of geographically distributed linux users accessing the same system, may be it is OK to keep it in UTC. But most of the time, it is better to have it in your local time zone.

Of course, no one checks the date and time on a Linux command line, because you can simply check the bottom of your computer or on your phone, or on the wall clock to know what time it is. But when you are comparing file times using ls -l, it can be very irritating to not understand the timestamps.

So here is the quick and simple solution to show the date and time in your local time zone. In this example I am using the America/Los_Angeles time zone. But you can use the one you want. You can find the whole list of American time zones under /usr/share/zoneinfo/America/ and the rest of the world in the parent directory.

In /etc/ there is a file called localtime. Delete it. If you are apprehensive, rename it to something else. Then do

ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Then

vi /etc/sysconfig/clock

Update the contents to

ZONE=”America/Los_Angeles”
UTC=true

Of course, use your time zone that you used for /etc/localtime.

Done. Now “date” and “ls -l” will work like it should.

Permanent link to this article: http://www.johnvarghese.com/how-to-make-a-linux-system-show-the-date-in-the-local-timezone/

Leave a Reply