Change Time Zone in Debian 10 / Debian 9
Using the correct timezone is important for many systems related tasks and processes. For example, the cron daemon uses the system’s timezone for executing cron jobs and the timestamps in the log files are based on the same system’s timezone.
The system’s timezone is set during the installation, but it can be easily changed at a later time. In this post, we will see how to change the timezone in Debian 10 / Debian 9.
The user you are logged in as must have sudo privileges to be able to change the system’s timezone.
Checking the Current Timezone
In Debian and other modern Linux distributions, the
timedatectl command allows you to display and set the current system’s time and timezone.
$ timedatectl Local time: Tue 2020-01-28 20:18:35 CET Universal time: Tue 2020-01-28 19:18:35 UTC RTC time: Tue 2020-01-28 19:18:34 Time zone: Europe/Belgrade (CET, +0100) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no
As shown on the output above, the system’s timezone is set to “Europe/Belgrade”.
Changing Timezone in Debian
Before changing the timezone, you’ll need to find out the long name for the timezone you want to use. The timezone naming convention usually uses a “Region/City” format.
To list all available time zones, you can either list the files in the
/usr/share/zoneinfo directory or use the
$ timedatectl list-timezones
$ timedatectl list-timezones Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara ........... Europe/Sarajevo Europe/Saratov Europe/Simferopol ...........
Once you identify which timezone is accurate to your location, run the following command as sudo user:
$ sudo timedatectl set-timezone Europe/Sarajevo
Verify the change by issuing the
$ timedatectl Local time: Tue 2020-01-28 20:33:57 CET Universal time: Tue 2020-01-28 19:33:57 UTC RTC time: Tue 2020-01-28 19:33:57 Time zone: Europe/Sarajevo (CET, +0100) System clock synchronized: yes systemd-timesyncd.service active: yes RTC in local TZ: no
Changing the Timezone by Creating a Symlink
If you are running an older version of Debian and the
timedatectl command is not present on your system you can change the timezone by symlinking
/etc/localtime to the timezone in the
Before using the new configuration, rename or unlink old configuration file as:
$ sudo mv /etc/localtime /etc/localtime.old
Then create a symbolic link of
/etc/localtime with new timezone settings file.
$ sudo ln -s /usr/share/zoneinfo/Europe/Sarajevo /etc/localtime
Your time zone has been changed successfully. Let’s check the timezone again.
$ date Tue Jan 28 20:42:19 CET 2020
That’s All. I hope you were able to set the correct time zone in your Debian 10 / Debian 9 system. Please share your feedback in the comments section.