If your Linux system time zone is not configured correctly, you will need to manually adjust to the correct local time zone. NTP synchronization of Time only calculates the offset between local time and UTC time, so configuring an NTP to synchronize the time does not resolve the problem of the incorrect time zone. So when you use a foreign cloud computing service provider such as Microsoft Azure or other VPS, virtual machines, you need to be aware of the same time zone as the Chinese mainland. View Linux Current time zone
You can easily see the Linux system's current time zone by using the following command:
Date
ls-l/etc/localtime
Get time zone TZ value
To change the Linux system time zone first you need to know the TZ value of your local time zone, and use the Tzselect command to view and select the installed time zone files. Execute tzselect command
Choose your continent, country, and city through a wizard
Tzselect will eventually output your time zone values in the Posix TZ format (for example, Asia/shanghai) and record this.
Change the time zone for each user
Linux users a multi-user system, each user can configure their own time zone, you can add a TZ environment variable for yourself:
Export tz= ' Asia/shanghai '
You need to log on to the system or refresh ~/.BASHRC after the execution is complete.
SOURCE ~/.BASHRC
Changing the Linux system time zone
To change the entire system-wide time zone for a Linux system, you can use the following command:
sudo rm-f/etc/localtime
sudo ln-s/usr/share/zoneinfo/asia/shanghai/etc/localtime
Note: The specific time zone in/usr/share/zoneinfo/asia/shanghai is replaced with the TZ value you get. Using SYSTEMD to change the Linux system time zone
If you use a Linux system that uses SYSTEMD, you can also use the TIMEDATECTL command to change the Linux system-wide time zone. Under SYSTEMD, a system service called systemd-timedated is responsible for adjusting the system clock and time zone, and we can use the TIMEDATECTL command to configure this system service.
sudo timedatectl set-timezone ' Asia/shanghai '
Finally, if you find Ubuntu with Windows dual system time is not synchronized, you can refer to our previous article instructions and solutions.
This article is reproduced from: http://www.linuxprobe.com/linux-time/
Free to provide the latest Linux technology tutorials Books, for the open source technology enthusiasts to do more and better: http://www.linuxprobe.com/