How To Change Time Zone in Ubuntu 18.04 / Ubuntu 16.04 & Linux Mint

0
Change Time Zone in Ubuntu 18.04
Change Time Zone in Ubuntu 18.04

It happens that sometimes you might have set the wrong time zone or forgot to set the right time zone at the time of installing Ubuntu or Linux Mint.

In this post, we will help you to change the time zone in Ubuntu and Linux Mint.

Change Time Zone In Ubuntu & Linux Mint

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 of original timezone) file to set the timezone for your system. This method will work on all Ubuntu and LinuxMint versions, including old ones.

Check the current time zone using the date command.

date

Output:

Tue Dec  3 09:29:00 UTC 2019

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

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

ls -al /etc/localtime

Output:

lrwxrwxrwx 1 root root 25 Dec  3 09:28 /etc/localtime -> ../usr/share/zoneinfo/UTC

The /usr/share/zoneinfo/ directory contains all the timezones. Beneath that you can find some directories specific to country or zone. Example: /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

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

Link either the city file or the zone with /etc/localtime file.

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

OR

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

Verify the timezone using the date command.

date

Output:

Tue Dec  3 04:30:10 EST 2019

2. Using timedatectl Command

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

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.

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 using grep for the city near to you or the continent.

sudo timedatectl list-timezones | grep -i new

OR

sudo timedatectl list-timezones | grep -i america

Output:

America/New_York
America/North_Dakota/New_Salem

Set the timezone using the following command.

sudo timedatectl set-timezone America/New_York

Verify the new timezone using the date command.

date

Output:

Tue Dec  3 04:31:28 EST 2019

Conclusion

That’s All. Please share your feedback in the comments section.

You might also like