For many system-related tasks and processes, it is important to use the correct time zone. For example, the cron daemon uses System time zone Used to execute cron jobs. The timestamp in the log file is based on the time zone of the same system. of System time zone Set during installation, but can be easily changed later. In this article we will see How to change the time zone in Debian 10 / Debian 9.
The user you are logged in must have sudo privileges to change the system’s time zone.
Check the current time zone
In Debian and other modern Linux distributions,
timedatectl Command allows you to display and set the currentSystem time and time zone.
$ 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 in the output above, the system’s time zone is set to “Europe / Belgrade”.
Changing the time zone in Debian
prior to Change time zone, You need to find the short name of the name Time zone You want to use. Time zone naming conventions typically use the “region / city” format. To list all available time zones, you can
/usr/share/zoneinfo Directory or use
$ timedatectl list-timezones
Lots of output:
$ timedatectl list-timezones Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara ........... Europe/Sarajevo Europe/Saratov Europe/Simferopol ...........
Once you determine which one Time zone To your exact location, run the following command Sudo user:
$ sudo timedatectl set-timezone Europe/Sarajevo
$ 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
Change the time zone by creating a symbolic link
If you are running an older version of Debian,
timedatectl This command is not available on your system, you can change the time zone via a symbolic link
/etc/localtime Time zone
/usr/share/zoneinfo table of Contents. Before using the new configuration, rename or unlink the old configuration file to:
$ sudo mv /etc/localtime /etc/localtime.old
Then create a symbolic link
/etc/localtime Use the new time zone settings file.
$ sudo ln -s /usr/share/zoneinfo/Europe/Sarajevo /etc/localtime
Your time zone has been successfully changed. Let’s check the time zone again.
$ date Tue Jan 28 20:42:19 CET 2020
that’s it. Hope you can set the right Time zone in Debian 10 / Debian 9 system. Please share your feedback in the comments section.