ubuntu 指令修改时区 tzselect

修改时区

tzselect 指令只是根据提示一步步选择正确时区,但不能真正修改时区,最后输入提示的指令,然后重启,才能永久修改。

aaron@ubuntu:~$ tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
) Africa
) Americas
) Antarctica
) Asia
) Atlantic Ocean
) Australia
) Europe
) Indian Ocean
) Pacific Ocean
) coord - I want to use geographical coordinates.
) TZ - I want to specify the time zone using the Posix TZ format.
#?
Please select a country whose clocks agree with yours.
) Afghanistan ) Israel ) Palestine
) Armenia ) Japan ) Philippines
) Azerbaijan ) Jordan ) Qatar
) Bahrain ) Kazakhstan ) Russia
) Bangladesh ) Korea (North) ) Saudi Arabia
) Bhutan ) Korea (South) ) Singapore
) Brunei ) Kuwait ) Sri Lanka
) Cambodia ) Kyrgyzstan ) Syria
) China ) Laos ) *
) Cyprus ) Lebanon ) Tajikistan
) East Timor ) Macau ) Thailand
) Georgia ) Malaysia ) Turkmenistan
) * ) * ) United Arab Emirates
) India ) Myanmar (Burma) ) Uzbekistan
) Indonesia ) Nepal ) Vietnam
) Iran ) Oman ) Yemen
) Iraq ) Pakistan
#?
Please select one of the following time zone regions.
) Beijing Time
) * Time
#? The following information has been given: China
Beijing Time Therefore TZ='Asia/Shanghai' will be used.
Local time is now: Thu May :: CST .
Universal Time is now: Thu May :: UTC .
Is the above information OK?
) Yes
) No
#? You can make this change permanent for yourself by appending the line
TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again. Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai
// 此时时区还没有修改成功
// 根据提示输入 TZ='Asia/Shanghai'; export TZ 但重启后又失效
aaron@ubuntu:~$ date
Wed May :: PDT
aaron@ubuntu:~$ sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[sudo] password for aaron:
// 更新时间时,提示没有安装 ntpdate
aaron@ubuntu:~$ sudo ntpdate time.windows.com
sudo: ntpdate: command not found
// 安装
aaron@ubuntu:~$ sudo apt-get install ntpdate
// 更新时间
aaron@ubuntu:~$ sudo ntpdate time.windows.com
May :: ntpdate[]: adjust time server 51.140.127.197 offset 0.044998 sec
aaron@ubuntu:~$ date
Thu May :: CST
// 重启
aaron@ubuntu:~$ sudo reboot
// 时区设置成功
aaron@ubuntu:~$ date
Thu May :: CST
上一篇:hadoop基础教程免费分享


下一篇:ntpdate[16603]: the NTP socket is in use