Change timezone in Ubuntu 18.04

Filed Under: Ubuntu

On Ubuntu, the system timezone is set during the installation process, but can be changed later.

Configuring the appropriate timezone is important for a lot of us, so let us find out how we can change the timezone on our Ubuntu 18.04 system.


Approach 1. Using timedatectl command

We can use the timedatectl command to display and set the current system’s time and timezone.

timedatectl
Ubuntu View Timezone
Ubuntu View Timezone

As you can observe, here, the timezone is currently set to UTC.

Let’s get this changed to IST (GST +5:30) using a few steps!

Find the timezone format for our required timezone

We need to find out the format for the timezone you want to use. The timezone naming convention usually uses a “Region/City” format.

To list all available time zones, we can use timedatectl along with the list-timezones option.

timedatectl list-timezones

We will get an output like this, showing the long name format for all available timezones.

Ubuntu View Timezone Options
Ubuntu View Timezone Options

Let us find out the required format for our necessary timezone, which we want to find; IST, in my case. It is in the Kolkata zone, so let’s grep for Kolkata.

timedatectl list-timezones | grep Kolkata
Ubuntu Search Ist Format
Ubuntu Search Ist Format

Now we have identified our timezone format. We just need to set it now!

Set the timezone

Use the below command to change the timezones, as root.

sudo timedatectl set-timezone your_time_zone

In my case, it is Asia/Kolkata, so the command will be

sudo timedatectl set-timezone Asia/Kolkata

Alternatively, we can also directly set the timezone to its abbreviated format (IST, in my case)

sudo timedatectl set-timezone IST
Ubuntu Change Timezone Successful
Ubuntu Change Timezone Successful

If this is successful, you will see the system time in terms of your timezone, and the timezone has been successfully updated!

But even if the above method didn’t work, we have some alternatives. So if you’ve configured timezone successfully using timedatectl, the rest of the article is not required. But otherwise, let’s keep reading.


Approach 2. Reconfigure Timezone Data

Suppose the above method didn’t work, we can use dpkg to reconfigure our timezone data and set the desired timezone.

sudo dpkg-reconfigure tzdata

We will now get a menu that allows us to reconfiguring our timezone.

Ubuntu Reconfigure Timezone
Ubuntu Reconfigure Timezone

Now, you can use the graphical menu to successfully update your timezone!


Approach 3. Change the /etc/localtime file

Method 1: Using Region Timezone details

Another way of changing the timezone would be to edit the localtime file manually.

Information about the timezone is located at /etc/localtime. We can manually modify that file to our desired timezone, which is located at /usr/share/zoneinfo/.

The zoneinfo directory contains a list of Regions of interest. Select your region. (For IST, the region is Asia)

Ubuntu Zoneinfo Files
Ubuntu Zoneinfo Files
Ubuntu Zoneinfo Asia
Ubuntu Zoneinfo Asia

Now, simply copy the Kolkata timezone file to /etc/localtime.

sudo cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

Restart the machine to apply your changes.

With this, we have now updated our timezone successfully!

Method 2: Using Timezones directly

We can also directly perform a symbolic link between the details of the Timezone file and /etc/localtime, located at /usr/share/zoneinfo/TIMEZONE, where TIMEZONE is your required timezone. In my case, it is IST.

sudo ln -sf /usr/share/zoneinfo/IST /etc/localtime

Again, restart your machine to apply the changes.

Now, we have shown you different methods for updating your timezone!


Conclusion

In this tutorial, we showed how you can change the timezone of your Ubuntu 18.04 system using various methods.


Afterword: Recommendations

While we have shown different approaches, usually, the recommended method depends on your background:

  • If you are a new user of Ubuntu coming from Windows, it is recommended that you use the GUI mode of changing the timezone, using dpkg, since it is user-friendly.
  • On the other hand, you have experience with Linux previously, but not using Ubuntu, you can manually change /etc/localtime.
  • Otherwise, if you are a day to day user of Ubuntu, timedatectl is your best bet!

Hope you found your answer by reading this tutorial!


Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages