To set the timezone in Debian/Ubuntu or CentOS, see these examples:
timedatectl set-timezone Europe/Berlin
timedatectl set-timezone Europe/London
timedatectl set-timezone Africa/Johannesburg
For a list of zones, use the first or the second (filtered) command:
timedatectl list-timezones timedatectl list-timezones | grep -i europe
Other useful date time commands
This one shows information compared to time sync:
timedatectl
Check if ntp service is running:
service ntp status
Install a more sophisticated time server service (see Notes below):
apt install ntp
Notes:
When you run the above command, you may get this:
Package systemd-timesyncd which provides time-daemon is to be removed
Locale
For some locales, e.g. for use with Firefly III, you might have to first generate the base locale. Warning, the command below might import a whole bunch of English locales that you’ll never use.
sudo apt-get install -y language-pack-en-base
To generate locales on your system, do this:
root@magic:~# locale-gen Generating locales (this might take a while)... en_US.UTF-8... done Generation complete.
To see all locales:
root@magic:~# locale -a C C.utf8 POSIX en_US.utf8
Your application might another locale, e.g. en_ZA. In that case, do this:
root@magic:~# locale-gen en_ZA.utf8 Generating locales (this might take a while)... en_ZA.UTF-8... done Generation complete. root@magic:~# locale -a C C.utf8 POSIX en_US.utf8 en_ZA.utf8
You could also do this:
locale-gen en_ZA
1 thought on “How to set the timezone in Linux and other useful time and locale commands”
great