`timedatectl set-timezone` doesn't update `/etc/timezone`
timedatectl
updates /etc/localtime
, which is the documented way of setting the default timezone in most Linux-based environments (along with its override, the TZ
environment variable, which is the only POSIX-defined way of specifying the timezone).
/etc/timezone
appears to be mostly Debian-specific (including derivatives). On Debian systems, timedatectl set-timezone
also updates /etc/timezone
.
If you manually update /etc/timezone
, you should also update the /etc/localtime
symlink (and make sure you keep the latter a symlink). Updates to /etc/localtime
appear to be taken into account by (most?) desktop environments, so there’s no need to use environment-specific tools to update the timezone.
If you’re running Debian, you should use dpkg-reconfigure tzdata
to configure the default timezone; that updates /etc/localtime
and /etc/timezone
as above, and it also updates the selected timezone in the debconf database (which serves as the default when configuring tzdata
). If you don’t do this, the next time tzdata
is updated, the timezone will be restored to the value in the debconf database. dpkg-reconfigure tzdata
also takes care of updating the SE Linux context, if you’re using SE Linux.
Related videos on Youtube
Tom Hale
Updated on September 18, 2022Comments
-
Tom Hale over 1 year
I expected that
timedatectl
would update/etc/timezone
when changing timezones, but no:% sudo timedatectl set-timezone 'Asia/Kuala_Lumpur' % cat /etc/timezone Asia/Bangkok
Is there a reason that it doesn't? (Bug?)
If I manually update
/etc/timezone
to matchtimedatectl set-timezone
, are there any side-effects I should be aware of?Is there anywhere else I should consider changing timezone, eg xfce4 panel clock?
-
Stéphane Chazelas almost 6 yearsI don't think many things use
/etc/timezone
,localtime()
and co. don't. if$TZ
is not set, what matters is /etc/localtime
-
-
Stéphane Chazelas almost 6 yearsAnd to answer Tom's other question, timedatectl is a systemd thing that queries timedated over dbus and timedated derives the name of the timezone (like
Europe/London
) by doing areadlink()
on/etc/localtime
. If/etc/localtime
is not a symlink, then that name cannot be derived as those timezone definition files don't contain that information. -
Stéphane Chazelas almost 6 yearsWhat's an official system software? What do you mean by UNIX? What documentation are you referring to?
-
schily almost 6 yearsSoftware delivered with the system. Typical UNIX systems are Solaris, AIX, HP-UX. FreeBSD.
-
Stéphane Chazelas almost 6 yearsI use
dpkg-reconfigure tzdata
on Debian to configure the system timezone. I assume it does what is needed. It does modify /etc/timezone and /etc/localtime -
Stéphane Chazelas almost 6 yearsDo any of those systems have a
timedatectl
command? -
schily almost 6 yearsNo, but the documented content of /etc/timezone is something like US/Eastern East.Sun.COM #Sun East Coast. Is this what
timedatectl
sets up? -
Stéphane Chazelas almost 6 yearsYou seem to be referring to the /etc/timezone file used by the sysidtool software on Solaris to build NIS maps. It is specific to Solaris.
timedatectl
is a systemd utility to interact with itstimedated
service, which suggests the OP is running a GNU/Linux system using systemd's init framework, more specifically, probably a Debian-based one as that/etc/timezone
file is mostly Debian-specific. See also 0pointer.de/public/systemd-man/timezone.html, out-of-date as systemd no longer uses that file even on Debian. -
Tom Hale almost 6 years
On Debian systems, timedatectl set-timezone also updates /etc/timezone
- Hmm, not so on Manjaro (Arch-based). I've let them know. -
Tom Hale almost 6 yearsThanks @StéphaneChazelas, you may be interested in this answer based on your comment.