Ubuntuでタイムゾーンの設定をCLIで変更するときの手順。GUIが使えるのならば、GUIでやった方が楽。
まずは、timedatectlコマンドで現在のタイムゾーンがどこなのかを確認する。
~$ timedatectl Local time: Tue 2019-06-25 06:01:14 UTC Universal time: Tue 2019-06-25 06:01:14 UTC RTC time: Tue 2019-06-25 06:01:15 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no
次に、”timedatectl list-timezones”で、タイムゾーンを表示させ、中から選ぶ。量が多いので、grepなどを使ってある程度絞り込むとよい。
次に、”timedatectl set-timezone タイムゾーン” で、変更後タイムゾーンを変更する。成功したかどうかの反応はないため、実行後に設定を確認する。
~$ sudo timedatectl set-timezone America/Los_Angeles ~$ ~$ timedatectl Local time: Mon 2019-06-24 23:02:41 PDT Universal time: Tue 2019-06-25 06:02:41 UTC RTC time: Tue 2019-06-25 06:02:42 Time zone: America/Los_Angeles (PDT, -0700) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no ~$
設定例(sudoを付けずに実行しているため、途中で失敗もしている)
ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ timedatectl list-timezones | grep -i america/Los America/Los_Angeles ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ timedatectl Local time: Tue 2019-06-25 06:01:14 UTC Universal time: Tue 2019-06-25 06:01:14 UTC RTC time: Tue 2019-06-25 06:01:15 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ timedatectl list-timezones | grep -i america/Los America/Los_Angeles ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ timedatectl set-timezone America/Los_Angeles ==== AUTHENTICATING FOR org.freedesktop.timedate1.set-timezone === Authentication is required to set the system timezone. Authenticating as: Ubuntu (ubuntu) Password: polkit-agent-helper-1: pam_authenticate failed: Authentication failure ==== AUTHENTICATION FAILED === Failed to set time zone: Access denied ubuntu@ip-10-0-0-122:~$ sudo timedatectl set-timezone America/Los_Angeles ubuntu@ip-10-0-0-122:~$ ubuntu@ip-10-0-0-122:~$ timedatectl Local time: Mon 2019-06-24 23:02:41 PDT Universal time: Tue 2019-06-25 06:02:41 UTC RTC time: Tue 2019-06-25 06:02:42 Time zone: America/Los_Angeles (PDT, -0700) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no ubuntu@ip-10-0-0-122:~$