Date
Date
Timezone setting
Choosing your timezone based on option
sudo tzselect
Change timezone file
sudo cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime
Time tick
sudo apt-get install ntpdate
sudo ntpdate time.stdtime.gov.tw
Writing timezone to the BIOS
sudo hwclock -w
Time tick every day
sudo crontab -e
cronjob
0 0 * * * /usr/sbin/ntpdate time.stdtime.gov.tw > /dev/null
if your
ntpdate
path is different from me, you can usewhich ntpdate
to check your real path
Show all available timezone
$ timedatectl list-timezones
$ timedatectl list-timezones
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/Conakry
Africa/Dakar
Africa/Dar_es_Salaam
Africa/Djibouti
Africa/Douala
Africa/El_Aaiun
Africa/Freetown
Africa/Gaborone
Africa/Harare
Africa/Johannesburg
Africa/Juba
Africa/Kampala
Africa/Khartoum
Africa/Kigali
Africa/Kinshasa
Africa/Lagos
Africa/Libreville
Africa/Lome
Africa/Luanda
Africa/Lubumbashi
Africa/Lusaka
Africa/Malabo
Africa/Maputo
Africa/Maseru
Africa/Mbabane
Africa/Mogadishu
Africa/Monrovia
Africa/Nairobi
Africa/Ndjamena
Africa/Niamey
Africa/Nouakchott
Africa/Ouagadougou
Africa/Porto-Novo
Africa/Sao_Tome
Africa/Tripoli
Africa/Tunis
Africa/Windhoek
America/Adak
Show all available timezone in Asia
$ timedatectl list-timezones | grep Asia
$ timedatectl list-timezones | grep Asia
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau
Asia/Aqtobe
Asia/Ashgabat
Asia/Atyrau
Asia/Baghdad
Asia/Bahrain
Asia/Baku
Asia/Bangkok
Asia/Barnaul
Asia/Beirut
Asia/Bishkek
Asia/Brunei
Asia/Chita
Asia/Choibalsan
Asia/Colombo
Asia/Damascus
Asia/Dhaka
Asia/Dili
Asia/Dubai
Asia/Dushanbe
Asia/Famagusta
Asia/Gaza
Asia/Hebron
Asia/Ho_Chi_Minh
Asia/Hong_Kong
Asia/Hovd
Asia/Irkutsk
Asia/Jakarta
Asia/Jayapura
Use timedatectl to check timezone setting
$ timedatectl
$ timedatectl
Local time: Tue 2021-08-31 11:13:12 CST
Universal time: Tue 2021-08-31 03:13:12 UTC
RTC time: Tue 2021-08-31 03:13:13
Time zone: Etc/UTC (CST, +0800)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
Setting timezone
$ timedatectl set-timezone <你要設定的時區>
$ timedatectl set-timezone Asia/Taipei
$ timedatectl
Local time: Tue 2021-08-31 11:25:01 CST
Universal time: Tue 2021-08-31 03:25:01 UTC
RTC time: Tue 2021-08-31 03:25:02
Time zone: Asia/Taipei (CST, +0800)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
$ timedatectl set-timezone Asia/Bangkok
$ timedatectl
Local time: Tue 2021-08-31 10:26:47 +07
Universal time: Tue 2021-08-31 03:26:47 UTC
RTC time: Tue 2021-08-31 03:26:47
Time zone: Asia/Bangkok (+07, +0700)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
/usr/share/zoneinfo/iso3166.tab: No such file or directory
$ sudo tzselect
/usr/bin/tzselect: line 180: /usr/share/zoneinfo/iso3166.tab: No such file or directory
/usr/bin/tzselect: time zone files are not set up correctly
If there is shown /usr/share/zoneinfo/iso3166.tab: No such file or directory
message, you can reinsall timezone package to solve this problem
sudo apt-get install tzdata
Reference
- [Ubuntu]Ubuntu 更改時區 | Philip@Swarchy
- Debian User Forums • View topic - Setting time zone
- 修改 Linux 系統時間、時區的設定 - TerryL