`timedatectl set-timezone` 不会更新 `/etc/timezone`

Tom*_*ale 8 linux arch-linux date timezone

我预计更改时区时timedatectl会更新,但没有:/etc/timezone

% sudo timedatectl set-timezone 'Asia/Kuala_Lumpur'
% cat /etc/timezone
Asia/Bangkok
Run Code Online (Sandbox Code Playgroud)

有没有理由不这样做?(漏洞?)

如果我手动更新/etc/timezone为 match timedatectl set-timezone,是否有我应该注意的副作用?

还有其他地方我应该考虑更改时区,例如xfce4 面板时钟吗?

Ste*_*itt 6

timedatectl更新/etc/localtime,这是在大多数基于 Linux 的环境中设置默认时区的记录方法(及其覆盖、环境变量,这是指定 timezone 的TZ唯一POSIX 定义的方法)。

\n

/etc/timezone似乎主要是 Debian 特定的(包括衍生品)。在 Debian 系统上,timedatectl set-timezone还会更新252.6-1 之前的/etc/timezonesystemd 版本(直到 Debian 11 包含在内)。

\n

如果您手动更新/etc/timezone,您还应该更新/etc/localtime符号链接(并确保将后者保留为符号链接)。(大多数?)桌面环境似乎考虑了更新/etc/localtime,因此 \xe2\x80\x99s 无需使用特定于环境的工具来更新时区。

\n

如果你\xe2\x80\x99运行的是Debian,你应该使用dpkg-reconfigure tzdata配置默认时区;/etc/localtime如上所述,它会更新/etc/timezone,并且还会更新 debconf 数据库中选定的时区(配置时作为默认值tzdata)。如果\xe2\x80\x99不这样做,下次tzdata更新时区将恢复为debconf数据库中的值。dpkg-reconfigure tzdata如果您\xe2\x80\x99 使用 SE Linux,还负责更新 SE Linux 上下文。

\n