This article mainly introduces how to use ubuntu to modify the time, display the hardware time, and synchronize the system clock (how to use the date command). If you need a friend, refer to the following label: Ubuntu
1. the date command is mainly used to display and modify the system time.
2. the hwclock command is used to view and set the hardware Time and synchronize the hardware Time and system time.
Copy codeThe code is as follows:
# Display hardware Time
Hwclock
# Set hardware Time
Hwclock-set-date = "03/24/14 22:22:00"
# Synchronize the hardware clock and system clock
Hwclock -- hctosys
# Synchronize the system clock and hardware clock
Hwclock -- systohc
3. ntpdate is used to synchronize the network time
Copy codeThe code is as follows:
Ntpdate cn.pool.ntp.org
4. modify the time zone tzselect command and navigate to sudo cp/usr/share/zoneinfo/Asia/ShangHai/etc/localtime
5. change Locale to/var/lib/locales/supported. d/local, for example:
Copy codeThe code is as follows:
En_US.UTF-8 UTF-8
Zh_CN.UTF-8 UTF-8
Zh_CN.GBK GBK
Zh_CN GB2312
Run locale-gen or sudo dpkg-reconfigure locales.
Locale rules: the Locale of Ubuntu is divided into 12 categories, that is, 12 LC _*. In addition to setting these 12 variables, there are two variables for convenience: LC_ALL and LANG. There is a priority relationship between them:
LC_ALL> LC _ *> LANG
It can be said that LC_ALL is set at the upper level or mandatory, while LANG is the default value. If you set LC_ALL = zh_CN.UTF-8, then no matter what the LC _ * and LANG are set to, they will be forced to obey the LC_ALL settings, become a zh_CN.UTF-8. If you set LANG = zh_CN.UTF-8, and other LC _ * = en_US.UTF-8, and no LC_ALL is set, then the locale of the system is set to LC _ * = en_US.UTF-8. If you set LANG = zh_CN.UTF-8, and other LC _ *, and LC_ALL are not set, the system will set LC _ * to the default value, that is, the LANG value zh_CN.UTF-8. If you set LANG = zh_CN.UTF-8, and other LC_CTYPE = en_US.UTF-8, other LC _ *, and LC_ALL are not set, then the locale setting of the system will be: LC_CTYPE = en_US.UTF-8, other LC_COLLATE, LC_MESSAGES, and so on will use the default value, that is, the LANG value, that is, LC_COLLATE = LC_MESSAGES = ...... = LC_PAPER = LANG = zh_CN.UTF-8. All in all, the locale setting rules are as follows:
If you need a Chinese-only system, you can set LC_ALL = zh_CN.XXXX or LANG = zh_CN.XXXX. of course you can set both, but as mentioned above, the value of LC_ALL overwrites all other locale settings. If you only want to enter a Chinese environment and keep the menu, title, and system information as an English interface, you only need to set LC_CTYPE = zh_CN.XXXX, LANG = en_US.XXXX. In this way, LC_CTYPE = zh_CN.XXXX, while LC_COLLATE = LC_MESSAGES = ...... = LC_PAPER = LANG = en_US.XXXX.
Finally, 12 types of Locale are attached:
LC_CTYPE = "en_US.UTF-8"
LC_NUMERIC = "en_US.UTF-8"
LC_TIME = "en_US.UTF-8"
LC_COLLATE = "en_US.UTF-8"
LC_MONETARY = "en_US.UTF-8"
LC_MESSAGES = "en_US.UTF-8"
LC_PAPER = "en_US.UTF-8"
LC_NAME = "en_US.UTF-8"
LC_ADDRESS = "en_US.UTF-8"
LC_TELEPHONE = "en_US.UTF-8"
LC_MEASUREMENT = "en_US.UTF-8"
LC_IDENTIFICATION = "en_US.UTF-8"