Linux system modification system time and time zone

Source: Internet
Author: User
Tags local time

Anyone who has installed a Linux system may have the experience that the machine has the right time to install the Windows system, but when the Linux system is installed, the system time is incorrect, even if the time zone is selected correctly. This is because UTC is used to install the system, so what is UTC, that is, UTC is the time of the 0 time zone, the international standard, and China is in the utc+8 time zone.
Another time is local time, and Windows uses local time. Therefore, when installing a Linux system, do not choose to use UTC.

  
Method/Step Modify the system time.

There are two Linux system clocks, one is the hardware clock, that is, the BIOS time, which is the time we see in CMOS setup, and the other is the system clock, which is the kernel time of the Linux system. When Linux starts, the system kernel reads the hardware clock settings, and the system clock is independent of the hardware. Sometimes we find that the system clock is inconsistent with the hardware clock, so we need to perform time synchronization and share the command usage of time settings and clock synchronization.

The date command sets the dates to October 11, 2017

----Date-s 10/11/17

Set the time to 0 points, 38 minutes, 50 seconds

----Date-s 00:39:50

Set the time to October 11, 2017 0:40 50 seconds (MMDDHHMMYYYY.SS)

----Date 101100402017.50

Hwclock/clock command to view, set hardware time

Viewing the system hardware clock

Hwclock--show or

Clock--show

Set Hardware time

Hwclock--set--date= "10/11/2017 00:50:00" (Month/day/year: minutes: seconds) or # clock--set--date= "10/11/2017 00:50:00" (Month/day/year: minutes: seconds)

  

synchronous system and hardware clock.

You can see that the hardware and system clocks differ by half an hour. can be synchronized using hwclock or clock,

The hardware clock is synchronized with the system clock:

# Hwclock--hctosys or # clock--hctosys Hctosys represents the hardware time, SYS represents the system time, i.e. the system clock is synchronized with the hardware clock

system clock and Hardware clock synchronization:

# Hwclock--SYSTOHC or # clock--SYSTOHC synchronize hardware clock with system clock

View Time

Method/Step 2
    1. Time zone settings:

      To start setting the time zone, refer to the information on the Internet, using the Tzselect command, and found that the Tzselect command only tells the way to set the time zone, not really to modify/etc/sysconfig/clock this file. In other words, the tzselect command simply tells us to select the time zone by setting the TZ environment variable, and then add the variable to the. profile file. Here's a quick introduction to how to set the time zone using the Tzselect command, and how to set the time zone by modifying the/etc/sysconfig/clock configuration file.

    2. Tzselect:

      Execute the tzselect command--Select asia--> Select china--> Select East China-beijing, Guangdong, Shanghai, etc--> and enter 1. Process such as:

    3. After executing the tzselect command to select the time zone, the time zone does not change, but the command finally prompts you to execute tz= ' Asia/shanghai '; Export TZ and add this line of command to the. Profile, then exit and log back in. Refer to the results as seen in the Date command, and the final time zone is shown as CST, China Standard Time.

    4. Modify the configuration file to modify the time zone

1, modify/etc/sysconfig/clock Zone=asia/shanghai

      

2, Rm/etc/localtime

3. Link to Shanghai time zone file

Ln-sf/usr/share/zoneinfo/asia/shanghai/etc/localtime

After performing the above procedure, restart the machine to see that the time zone has changed.

     

Linux system modification system time and time zone

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.