Setting a Timezone on Debian or any other operating system is not limited to setting the date and time, but it also affects the working of system applications. Wrong or incorrect time zones can impact the scheduled tasks, network communication, system log files, file timestamps, email timestamps, and more. So whenever installing a new Debian system or changing the system location, setting the timezone is necessary. To set or change the timezone on Debian 12 there are multiple ways like using timdatectl utility. This article will elaborate on setting the Timezone on Debian 12.
5 Ways To Set the Timezone on Debian 12
Timezones are primarily based on geographical locations which standardize time, resulting in making it easy to conduct business, schedule tasks, and more over long distances. There are 5 ways to set a Timezone on Debian:
1: Set Timezone using timedatectl Command
On Debian and other Linux operating systems, there are primarily two types of tools for synchronizing the system clock. One of which is systemd that use the timedatectl command. To view the current Timezone on Debian use timedatectl command:
timedatectl
The first step for setting the timezone on Debian is to list down all the available regions and for that execute the below command:
timedatectl list-timezones
Here, press Enter to keep moving the list and see which timezone relates to your location:
Since the list is quite long, and it might take a while to go through all, you can add the country filter by using the below syntax:
timedatectl list-timezones | grep -i [desired-timezone-area/country]
Once, you have selected the country and state then use the set-timezone command as in the syntax below:
sudo timedatectl set-timezone [desired-country-and-state]]
Here, I have set my time zone to Saskatchewan, Canada:
Now, you can verify the timezone settings by executing the timedatectl command:
timedatectl
2: Set the Timezone Using tzdata Package
The next method to change or set Timezone on Debian 12 is using the tzdata package which is essentially used for timekeeping and time zone management. It contains the IANA Time Zone Database. This database has a vast collection of time zone definitions for various locations around the world. To set the timezone using tzdata execute:
sudo dpkg-reconfigure tzdata
Here, prompt the process by selecting OK after reading the instructions:
First, select the Geographical area related to your current location and proceed to the next step:
Next based on the selected geographical area select the relevant city or region corresponding to your time zone and click on OK:
Once the timezone is selected you will see as in the image below the timezone has been changed:
3: Set Timezone tzselect Menu
The third method to set or change the timezone on Debian 12 is using the tzselect utility, it is a user-friendly tool that allows you to interactively set your Debian timezone. To launch this tool execute the below command:
tzselect
Here, you will see three options for selecting the timezone first is selecting the continent or ocean. The next is using the coordinates(coord) or using the TZ format. Here I have selected the first option, the continent or ocean option:
Next, after selecting the ocean or continent, select the desired country:
I have selected the Faroe Islands just for illustration and next the confirmation message will appear:
Now another prompt will appear asking you to enter a number in the range, so in that case enter 1. Next, you will see an instruction for making the change in timezone permanent:
To make the change in the timezone permanent add it to the Debian profile by running the following command:
echo "TZ='Atlantic/Faroe'; export TZ" >> ~/.profile
To verify the timezone change, you can use the timedatectl command:
timedatectl
Alternatively, the second method to set the timezone on Debian is using the tzselect utility by entering the coordinates of the location. Here, first I have selected the coordinate method and then entered the coordinates of the desired region. Next, a list of various regions appeared, from which I had to select the time zone:
Here, I have selected Central Standard Time (CST) and the rest of the process is the same:
Another method to set the Time zone using the tzselect utility is selecting the TZ format:
4: Using Symlink File for Local Time
The next method to set the timezone on Debian is by manually configuring the local time file. However, before setting the timezone on Debian it is better to list all the states or regions of the desired country:
ls /usr/share/zoneinfo/[Country-Name]/
Here, I have listed all the regions of Canada:
Next, create a symbolic link for the desired time zone by stating the country and region in the local time file as in the below syntax:
sudo ln -sf /usr/share/zoneinfo/[country/state-or-region] /etc/localtime
To verify the changes you can see the permissions, along with the data in the local time file by executing:
ls -l /etc/localtime
Here, you can see the desired country and its region is added:
Further, you can also verify the timezone settings by using the timedatectl command:
timedatectl
5: Setting Timezone From Date & Time settings
The last method to set or change the timezone on Debian is by using the Date & Time settings under the Debian Settings app. First, unlock the settings:
Next, click on the Time Zone option :
Next, there are two ways to set the time zone, one is by searching the respective city or country. This method can be a little difficult as you may not find some cities:
The other way around is directly selecting the region using the map pin, simply click on the desired area on the map to set the time zone on Debian:
Next, you will see that the time zone has been changed:
Conclusion
To set or change the time zone on Debian 12 there are 5 ways which include using timedatectl command, tzdata package, tzselect tool, manually writing the local time file, and using the Debian Date & Time settings. The best and easiest way to set or change the Time Zone on Debian is using the timedatectl command because you can list different regions and set it to the desired time zone with just one command.