What's the best approach for configuring the Time Zone non-interactively?
Previously for hostname
, I've used
sudo raspi-config nonint do_hostname
However, I am unable to locate the equivalent command for timezone
?
The time zone is set by a symbolic link from /etc/localtime
to a file in the /usr/share/zoneinfo
directory.
The time zone needs to be in the form 'Area/Location' where these conform to the standards used in Linux. E.g. for Area use Africa, America, Antarctica, Arctic, Asia, Atlantic, Australia, Europe, Indian, and Pacific.
For Location use the name of a specific location within the Area. This is usually a city or small island.
See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for details
For example for New Zealand use Pacific/Auckland
/etc/localtime
, otherwise /etc/timezone
will be overwritten./etc/timezone
The commands I run are;
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
sudo rm /etc/timezone
Edit: Now I'm looking at it I don't exactly know why I'm removing /etc/timezone
. Eeek!
timedatectl
, abstractions are your friend.
man timedatectl