Linux, Windows, Virtualization, OpenSource & Blogging

2 Methods to Change Timezone in Debian 9 / 8 & Ubuntu 16.04 / 14.04 / LinuxMint 18

0

It happens that sometimes you may have set the wrong timezone on the system or forgot to set the proper timezone at the time of installing Debian or Ubuntu.

In this post, we will help you how to change the timezone in Debian, Ubuntu, and LinuxMint.

Change timezone in Debian

We can change timezone in two ways,

  1. Using /etc/localtime
  2. Using timedatectl command

Let us get straight into the topic.

Method 1

In this method, will use /etc/localtime (link of original timezone) file to set the timezone for your system. This method will work on all Debian, Ubuntu and LinuxMint version, including old ones.

Check the current time zone using the date command.

date

Output:

Sun Oct 22 15:00:19 UTC 2017

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

The /usr/share/zoneinfo/ directory contains all the timezones. Beneath that you can find some directories specific to country or zone, Ex: /usr/share/zoneinfo/America/ directory contains only American timezones.

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

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

ls -al /etc/localtime

Output:

lrwxrwxrwx 1 root root 23 Sep 19 00:17 /etc/localtime -> /usr/share/zoneinfo/UTC

Unlink the timezone.

unlink /etc/localtime

Now, create a link with the desired timezone. In my case, it is Eastern (EDT) timezone.

ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime

Verify the timezone using date command.

date

Output:

Sun Oct 22 11:29:09 EDT 2017

Method 2

In this method, we will use the timedatectl command to change the timezone in Debian and Ubuntu. This method will only work on latest versions of Debian, Ubuntu, and LinuxMint.

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

date

Output:

Sun Oct 22 15:00:19 UTC 2017

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

Use the following command to list all time zones.

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 using grep for New York.

timedatectl list-timezones | grep -i new

Output:

America/New_York
America/North_Dakota/New_Salem

Set the timezone using the following command.

timedatectl set-timezone America/New_York

Verify the new timezone using “date” command.

date

Output:

Sun Oct 22 11:05:19 EDT 2017

That’s All.

POSTS YOU MAY LIKE -:)

You might also like

2 Methods to Change Timezone in Debian 9 / 8 & Ubuntu 16.04 / 14.04 / LinuxMint 18

0