How to adjust the Linux system to the correct time zone __linux

Source: Internet
Author: User
Tags local time

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.