dpkg-reconfigure -f noninteractive
not very intuitive.
I want to point out another way.
A. debconf frontend: teletype
It's a hidden option (seems debconf builtin frontend).
echo -e 'Asia\nTokyo' | sudo dpkg-reconfigure tzdata -f teletype
It's easy to read and write.
debconf frontends
see all frontends (but no teletype
listed)
dpkg-reconfigure debconf
or
dpkg-reconfigure debconf -f teletype
- Dialog
- Readline
- Gnome
- Kde
- Editor
- Noninteractive
check timezone
$ ll /etc/localtime; tail -v /etc/timezone
lrwxrwxrwx 1 root root 30 Apr 30 02:59 /etc/localtime -> /usr/share/zoneinfo/Asia/Tokyo
==> /etc/timezone <==
Asia/Tokyo
NOTE: sometimes maybe you need rm /etc/localtime
first (if it is broken link).
B. manually edit file
maybe off-topic
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
echo 'Asia/Tokyo' > /etc/timezone
OR
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
apt install tzdata # it will use the linked timezone
OR
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
dpkg-reconfigure tzdata # it will use the linked timezone
tested on ubuntu18 & 20