Modify the time zone using the command line in Linux

  
                  

Linux uses the UTC format as the standard time format by default. If you run the program under Linux and specify a time zone different from the system in the program, it may cause a time error. If it is the desktop version of Ubuntu, you can modify the time zone information directly in graphics mode, but if it is in the Server version, you need to modify the time zone information through tzconfig. How to use (such as setting the time zone to Asia/Chongqing): sudo tzconfig Then follow the prompts to select the serial number corresponding to Asia. After the selection, a bunch of new prompts will be displayed—enter the city name, such as Shanghai or Chongqing, and finally sudo date - s "" to modify the local time. During the operation, it was found that Ubuntu7.10 Server does not support the tzconfig tool. In this case, you need to use tzselect to modify the time. The usage is similar to the tzconfig tool, except that the prompt information is slightly different from the selected information (with tzconfig). The difference is that you need to execute this command after setting: sudo cp /usr/share/zoneinfo/Asia/ShangHai /etc/localtime). Example: tzselect Follow the prompts to select the time zone, then: sudo cp /usr/share/zoneinfo/Asia/ShangHai /etc/localtime Execute sudo ntpdate cn.pool.ntp.org cn.pool.ntp.org is a public NTP located in China Server, used to synchronize your time (if your time is different from the server's time, you may not be able to synchronize the time, even instructions like sudo reboot can't be executed).

Copyright © Windows knowledge All Rights Reserved