Changing the timezone after installation

If the timezone is not set or is wrong, the superuser can run tzconfig to configure it after the operating system is installed and with latest releases it is actually –

dpkg-reconfigure tzdata

If there are other users, it is a good idea to notify then that the system Timezone has changed.

Setting the TZ environment variable.

If you do not have root privileges or want to set for yourself a different timezone than the one the system uses, you can set the environment variable TZ. Use the command tzselect to show what value to use for TZ and place it on your .bashrc or .profile file.

If you want everyone will see the changes then export that value on /etc/profile and /etc/timezone file.

To change the computer to use UTC after installation, edit the file /etc/default/rcS, change the variable UTC to no. If you happened to install your system to use local time, just change the variable to yes to start using UTC. It is best to reboot after editing /etc/default/rcS to get the changes effective.

Syncing time, rdate/ntpdate and NTP

If you have another Unix computer which you know keeps the correct time, with root privileges you can set the time with the command rdate. For example:


Even if you do not have an accurate time source, it is still a good idea to set all your computers to the same time, so that you can compare time stamps between hosts. To keep the clocks synchronized, You can start rdate once daily from cron.

Setting time at system boot

If the hardware clock does not keep the correct time, it is possible to set the correct time when the operating system boots. For this, there must be some other host in the LAN where the time can be received. Here is an example:


case “$1” in
exit 0

chmod 751 /etc/init.d/rdate

update-rc.d setdate defaults
OR Create a symbolic link to that file in directory /etc/rc2.d
ln -s /etc/init.d/rdate /etc/rc2.d/S19rdate

Setting time using NTP

If you are connected to the Internet, you can install an NTP client, for example ntp or xntp3 in Debian version 2.1 and older. This uses the Network Time Protocol RFC 1305 to synchronise clocks to a few tens of milliseconds precision.

See the excellent documentation that comes with ntp, in the Debian package ntp-doc. It is very thorough and thus long. If you think reading documents is a waste of time, just ask your Internet Service Provider or system administrator for NTP server names, or look up the nearest one in “List of Public NTP Servers” in . If you start using an NTP server, it is usually polite to notify the server’s administrator of the fact.

Do not configure your system to query level 1 NTP servers! If you think you need to do this, you are almost certainly wrong!

Once you know an NTP server, edit the file /etc/ntp.conf to add at least one server line. Here is an example:

# /etc/ntp.conf, configuration for xntpd

logfile /var/log/xntpd
driftfile /var/lib/ntp/ntp.drift
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

server ntp.somedomain.something
server ntp.something.else

Note, that I changed the actual server name in the above example, to prevent all Debian GNU/Linux users from blindly using that one server. Everything else except the server lines was there after xntp3 installation.

If you do not have a permanent Internet connection, then running NTP client is not a good solution. NTP client syncronizes relatively often, and needs the Internet connection to be always on. If you have a dial up Internet connection, you can run the command ntpdate (also in ntp package) to syncronize each time you connect.

Another possibility is to set cron to run ntpdate once daily, this gives good accuracy for most uses. The following is an example script that can be started from cron and runs ntpdate. This scripts assumes the /etc/ntp.conf is correctly set up, since it gets the server names from that file.

dilbert# cat /etc/cron.nightly/ntpdate
# Last modification: Sat Aug 8 05:27:07 EEST 1998
# ntpdate cron nightly


if [ -f $NTPCONFFILE ] ; then
echo “===========================” >> $LOGFILE
echo “<<> $LOGFILE
for i in `grep ^server $NTPCONFFILE | $CUT –fields 2 –delimiter \ `
echo “>>> `date` ” >> $LOGFILE

exit 0


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: