If the default timezone of your Linux system is not correct, you need to correct it to get accurate local time. Note that configuring NTP is not a solution for an incorrect timezone as NTP itself does not handle timezones. NTP handles time data in UTC, and actual local time is calculated by adding the local time zone offset. Thus you need to change the timezone separately yourself.
Check the Current Timezone
You can easily find out the current timezone of your Linux system with:
Obtain a TZ Value of your Timezone
The first step to change the timezone of your Linux system is to obtain a timezone value ("TZ value") of your region.
For that, you can use tzselect command, which allows you to view and choose installed timezone files.
Go through timezone selection menu to identify your zone.
tzselect will display your timezone in Posix TZ format (e.g., "America/New_York"). This is the TZ value of your region. Make a note of this value, and proceed next.
Change the Timezone on Per-User Basis
If you want to change timezone for a specific user only, you can define TZ environment variable using the TZ value you obtained earlier. Add the following in ~/.bashrc as follows.
Then re-login or execute ~/.bashrc to activate the change.
Change Timezone System-wide
To change the timezone on Linux system-wide, use the following commands.
$ sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
Note that the path to the timezone file (/usr/share/zoneinfo/America/New_York) is constructed from the TZ value you obtained earlier.
After the system-wide timezone can be set up like this, you can still override it by defining TZ environment variable in ~/.bashrc
Change Timezone System-wide under Systemd
If your Linux system uses systemd, there is another way to change timezone system-wide, which is by using timedatectl command.
Under systemd, there is a system service called systemd-timedated whose responsibility is to adjust system clock and timezone. The timedatectl command configures this system service.
To change the current timezone system-wide with timedatectl:
Use the TZ value you obtained above.
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!