Changing time,date,zone in Linux

In /etc the file, localtime, is a link to or copy of a file containing information about your time zone. Zone information files are usually in /usr/share/zoneinfo but this depends on your distribution. So if your localtime file points to a zone info file that is not your time zone you can change it by browsing the directories in /usr/share/zoneinfo to find your country, then find your city or a city in the same time zone and link localtime to it.

Changing the date and time

Changing the date and time requires two steps. First, Linux’s date and time must be changed and then the new time has to be written to the hardware clock.
The date command can be used for both viewing and changing the date and time.

To change the time use date followed by the month, day, hour, minute, and year all numeric and no spaces. So, to set the date and time to November 2nd, 2003 12:57

The hardware clock can be updated in UTC (coordinated universal time) or your local time. It is standard practice to update it in UTC.

To update it to your local time leave off the –utc or add –localtime and leave off the –utc.


The date and time can be changed directly to the hardware clock and then used to update the system clock.

Using NTP (Network Time Protocol)

NTP will connect to a server to get the atomic time. It can be downloaded from To get started with NTP simply download it, install it, use the ntpdate command followed by a public time server, and update your hardware clock.

A public time server can be found at

To keep your time accurate you can create a cron job that executes:
(the -w option is the same as –systohc)

To stay independent of a particiluar server you can use (0, 1, or 2) for the server name. This domain uses DNS round robin to choose different time servers every so often. This keeps certain nameservers from having high loads. The only disadvantage is the increased potential of updating time from a nameserver who is in the pool but has an incorrect time settings.

These are volunteer public servers so be polite, do not constantly access the public servers, use only public servers (not private), and if you have multiple machines, set up a ntp server and have your other machines retrieve the time from your local server. Check for detailed rules.

Using rdate

rdate is a different package that is used in the same way that ntpdate is. It doesn’t support running your own time server like NTP does, but can access the same time servers.

Please follow and like us:
About shk

shk is a DevOps engineer with more than 12 years of experience in different organizations. He enthusiastic about learning new technologies and shares his knowledge through his blogs.

Comment Policy:

Your words are your own, so be nice and helpful if you can. Please, only use your real name, not your business name or keywords. Using business name or keywords instead of your real name will lead to the comment being deleted. Anonymous commenting is not allowed either. Limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.

Tell us what you're thinking...

All comments are moderated.

* Denotes required field.



Previous Post:
Next Post: