How To Change Time Zone in Debian 11 / Debian 10 / 9

0

It happens that sometimes your system may have the wrong time zone or want to change the time zone due to the nature of working or forgot to set the right time zone at the time of installing the Debian operating system.

In this post, we will see how to change the timezone in Debian 11 / Debian 10.

Change Time Zone in Debian 11 / Debian 10

We can change timezone in two ways,

1. Using /etc/localtime file

2. Using timedatectl command

1. Using /etc/localtime File

In this method, we will use /etc/localtime (link to the original time zone file) file to set the timezone for your system. This method will work on all Debian versions, including old ones.

Check the current time zone using the date command.

date

Output:

Sun Aug  22 09:42:31 UTC 2021

You can see that my system has been configured with Coordinated Universal Time (UTC).

As I said earlier, the /etc/localtime is a link to the original timezone file. You can check the symbolic link using the following command.

ls -al /etc/localtime

Output:

lrwxrwxrwx 1 root root 30 Aug 17 02:21 /etc/localtime -> /usr/share/zoneinfo/UTC

The /usr/share/zoneinfo/ directory contains all the timezones. Beneath that you can find directories specific to a country or zone. Example: /usr/share/zoneinfo/America/directory contains American time zones.

ls /usr/share/zoneinfo/America/

Output:

Adak            Campo_Grande   Eirunepe      Iqaluit        Merida          Porto_Acre     St_Johns
Anchorage       Cancun         El_Salvador   Jamaica        Metlakatla      Port_of_Spain  St_Kitts
Anguilla        Caracas        Ensenada      Jujuy          Mexico_City     Porto_Velho    St_Lucia
Antigua         Catamarca      Fortaleza     Juneau         Miquelon        Puerto_Rico    St_Thomas
Araguaina       Cayenne        Fort_Nelson   Kentucky       Moncton         Punta_Arenas   St_Vincent
Argentina       Cayman         Fort_Wayne    Knox_IN        Monterrey       Rainy_River    Swift_Current
Aruba           Chicago        Glace_Bay     Kralendijk     Montevideo      Rankin_Inlet   Tegucigalpa
Asuncion        Chihuahua      Godthab       La_Paz         Montreal        Recife         Thule
Atikokan        Coral_Harbour  Goose_Bay     Lima           Montserrat      Regina         Thunder_Bay
Atka            Cordoba        Grand_Turk    Los_Angeles    Nassau          Resolute       Tijuana
Bahia           Costa_Rica     Grenada       Louisville     New_York        Rio_Branco     Toronto
Bahia_Banderas  Creston        Guadeloupe    Lower_Princes  Nipigon         Rosario        Tortola
Barbados        Cuiaba         Guatemala     Maceio         Nome            Santa_Isabel   Vancouver
Belem           Curacao        Guayaquil     Managua        Noronha         Santarem       Virgin
Belize          Danmarkshavn   Guyana        Manaus         North_Dakota    Santiago       Whitehorse
Blanc-Sablon    Dawson         Halifax       Marigot        Ojinaga         Santo_Domingo  Winnipeg
Boa_Vista       Dawson_Creek   Havana        Martinique     Panama          Sao_Paulo      Yakutat
Bogota          Denver         Hermosillo    Matamoros      Pangnirtung     Scoresbysund   Yellowknife
Boise           Detroit        Indiana       Mazatlan       Paramaribo      Shiprock
Buenos_Aires    Dominica       Indianapolis  Mendoza        Phoenix         Sitka
Cambridge_Bay   Edmonton       Inuvik        Menominee      Port-au-Prince  St_Barthelemy

Now, create a link with the desired time zone file. In my case, it is the Central Standard Time (EST) timezone. Chicago falls under the CST time zone.

You can link either the City or the Zone to /etc/localtime.

sudo ln -sf /usr/share/zoneinfo/US/Central /etc/localtime

OR

sudo ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

Verify the timezone using the date command.

date

Output:

Sun Aug 22 03:42:55 CST 2021

2. Using timedatectl command

In this method, we will use the timedatectl command to change the time zone in Debian. This method will only work on the latest versions of Debian.

Let us check the current time zone using the date command.

date

Output:

Sun Aug  22 09:44:50 UTC 2021

You can see that my system has been configured with Coordinated Universal Time (UTC).

Use the following command to list all time zones.

sudo timedatectl list-timezones

Output:

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
.     .     .
.     .     .
Pacific/Pohnpei
Pacific/Port_Moresby
Pacific/Rarotonga
Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis
UTC

You can filter the output with the city nearer to you or the continent. Chicago falls under the CST time zone.

sudo timedatectl list-timezones | grep -i chicago

OR

sudo timedatectl list-timezones | grep -i america

Output (For City):

America/Chicago

Set the timezone using the following command.

sudo timedatectl set-timezone America/Chicago

Verify the new timezone using the date command.

date

Output:

Sun Aug  22 03:45:37 CST 2021

Conclusion

That’s All. I hope you were able to set the right time zone in your Debian 11 / Debian 10 system.

You might also like