# 前置條件 你需要有 **root** 或是 **sudo** 的權限才能更改系統的時區 # 檢查當前時區 在 Ubuntu 中,我們有三種方式查看當前時區設定 ## 1. 使用 `timedatectl` 命令顯示當前的系統時區。 ``` timedatectl ``` ```result                     Local time: Fri 2021-01-07 22:45:47 UTC                 Universal time: Fri 2021-01-07 22:45:47 UTC                       RTC time: Fri 2021-01-07 22:45:48                       Time zone: Etc/UTC (UTC, +0000)       System clock synchronized: yes systemd-timesyncd.service active: yes                 RTC in local TZ: no ``` ## 2. 查看 `/etc/localtime` 的連結指向 ``` ls -l /etc/localtime ``` ```result lrwxrwxrwx 1 root root 33 Jan 8 15:57 /etc/localtime -> ../usr/share/zoneinfo/Etc/UTC ``` ## 3. 查看 `/etc/timezome` 的內容 ``` cat /etc/timezone ``` ```result Etc/UTC ``` # 修改時區 當我們檢查完時區後,接下來就是修改時區。不過假如你不知道要改的時區名稱,你可以透過以下指令來查看 ``` timedatectl list-timezones ``` ```result ... Asia/Seoul Asia/Shanghai Asia/Singapore Asia/Srednekolymsk Asia/Taipei Asia/Tashkent Asia/Tbilisi Asia/Tehran Asia/Thimphu Asia/Tokyo ... ``` 找到要修改的時區名稱後,接下就是以 sudo 權限執行以下命令 ``` sudo timedatectl set-timezone 要修改的時區名稱 ``` 例如要將系統修改為台北時區 `Asia/Taipei`,請輸入 ``` sudo timedatectl set-timezone Asia/Taipei ``` 使用 `timedatectl` 指令確認時區是否正確修改 ``` timedatectl ``` ```result                     Local time: Fri 2021-01-08 18:38:49 CST                 Universal time: Fri 2021-01-08 10:38:49 UTC                       RTC time: Fri 2021-01-08 10:38:49                       Time zone: Asia/Taipei (CST, +0800)       System clock synchronized: yes systemd-timesyncd.service active: yes                 RTC in local TZ: no ``` # 參考 - [如何正確修改 Ubuntu 18.04 的系統時區](https://www.hanktsai.com/2021/01/configure-ubuntu1804-timezone.html)