http://ask.xmodulo.com/change-timezone-linux.html
For that, you can use tzselect command, which allows you to view and choose installed timezone files.
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.
Then re-login or execute ~/.bashrc to activate the change.
After the system-wide timezone can be set up like this, you can still override it by defining TZ environment variable in ~/.bashrc
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:
Question: The current timezone of
my Linux box is inaccurate, and I want to change the timezone of the
system. How can I change time zone on Linux?
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:
$ date
$ ls -l /etc/localtime
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.
$ tzselect
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.
1
| export TZ= 'America/New_York' |
$ source ~/.bashrc
Change Timezone System-wide
To change the timezone on Linux system-wide, use the following commands.
$ sudo rm -f /etc/localtime
$ 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.$ sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime
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:
$ sudo timedatectl set-timezone 'America/New_York'
Use the TZ value you obtained above.
No comments:
Post a Comment