LoginSignup
1
1

Linux(Ubuntu)でタイムゾーンを変更する方法

Last updated at Posted at 2023-10-17

タイムゾーンの確認

$ date

Tue Oct 17 21:12:28 UTC 2023

timedatectl というコマンドでも確認できます。時刻関連の情報が複数行出てくるので Time zoneでgrep。

$ timedatectl | grep 'Time zone'

               Time zone: UTC (UTC, +0000)

変更

この timedatectl コマンドに set-timezone があるのでそちらで指定できます。

sudo timedatectl set-timezone Asia/Tokyo

確認

$ date

Tue Oct 17 21:12:28 JST 2023

$ timedatectl | grep 'Time zone'
                 Time zone: Asia/Tokyo (JST, +0900)

念のため再起動してもそのままになっていることを確認しておきます。

実態について

タイムゾーン設定の実態は、/etc/localtime にあるファイル(シンボリックリンク)で決定されている様子。

ls -latr /etc/localtime

lrwxrwxrwx 1 root root 30 Oct 17 21:10 /etc/localtime -> /usr/share/zoneinfo/Asia/Tokyo

なので実際には /usr/share/zoneinfo/ で指定したいタイムゾーンファイルを見つけてシンボリックリンクを貼る、という方法でもOKです。

参考:

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1