Javatpoint Logo
Javatpoint Logo

Linux Change Timezone

In this article, we are going to discuss how we can change the change or modify the timezone in Linux. On all Linux distros, we can modify the timezone with the help of the terminal, or we can apply the selection menu inside the terminal for distinct Linux distros.

A time zone can be defined as a geographical region that includes a similar standard time. The time zone is typically set at the time of the operating system's installation, but it could easily be modified at a later time. Using an accurate time zone is necessary for several systems-related processes and tasks. For instance, the cron daemon applies the time zone of the system to execute the cron jobs. Also, the time zone is used for many logs timestamps.

If we are using Ubuntu, Mint, or any other distro along with a general setting menu or user interface, then also we can change the settings of the timezone from there.

Checking the Time Zone (Current)

A command-line utility, i.e., timedatectl permits us to view and modify the time and date of the system. It is present on every latest systemd-based system of Linux.

We will need to invoke the command without the arguments and options, i.e., timedatectl to view our current time zone.


Linux Change Timezone

The time zone of the system is constructed by symlinking a file, i.e., /etc/localtime to the identifier of a binary time zone within a directory, i.e., /usr/share/zoneinfo.

Techniques To Change The Time Zone

There are some of the essential techniques which we can use to change the time zone of our system. These techniques are listed and discuss below:

Technique 1: Using Terminal

1. Open the command line from our Linux programs or we can click the Ctrl+Alt+T keys on our keyboard.

2. Enter the date command in the terminal to see our latest time zone and hit the Enter button. The terminal will show the date in a format, i.e., Weekday Month Day Time TimeZone Year.

Linux Change Timezone

For example, we might see Sun Jul 2 07:38:23 EDT 2021 (where EDT stands for Eastern Daylight Time and defines the latest time zone).

3. Enter the command, i.e., cd /usr/share/zoneinfo directory to see available time zones, and hit the Enter button. Then, enter the tzselect command and hit the Enter button to show the location's list.

Linux Change Timezone

Note: The directory cd /usr/share/zoneinfo may vary based on our Linux distro.

4. Enter inside the selection number that belongs to our normal location to choose an ocean or continent, then hit the Enter button.

5. Enter inside the selection number using an on-screen list to choose a country and hit the Enter button.

Linux Change Timezone
Linux Change Timezone

6. Enter inside the selection number to choose a preferred region of the time zone for selecting a time zone and hit the Enter button.

Note: If our selected city is not mentioned inside the list of the time zones, then select a distinct city from our similar time zone.

7. In the below prompt, make sure that the local time is accurate by entering 1 for confirming the local time and click the Enter button.

Linux Change Timezone

Note: If the time is not accurate, then type 2 and click Enter. Then, choose a new ocean and repeat this process.

8. Again, execute the date command and verify that the time zone relates to that one we just modified to for verifying that our time zone is set. If we see that the new time zone is listed, it means we have successfully modified the time zone of our computer.

Linux Change Timezone

9. Most of the latest distros have NTP installed already on their systems. If our Linux distro doesn't, we will require to install the package of the NTP server to set our clock to be synced with the time servers of the Internet if we like. We can use the below commands for installing it, based on our Linux distro:

  • Debian/Mint/Ubuntu: If we are using any one of these Linux distros, then we can use the below command:

Linux Change Timezone
  • RedHat/Fedora: If we are using this Linux distro, then we can use the below command:
  • CentOS: If we are using this Linux distro, then we can use the below command:

Technique 2: Timezone Selection Menu

1. Choose the terminal program through our Linux programs to open the terminal or press the Ctrl+Alt+T keys on our keyboard.

2. We will need to enter the command of the time zone menu. This command may vary based on our Linux distros:

  • Mint and Ubuntu: If we are using this Linux distro, then we can use the below command:

Linux Change Timezone

This command should be followed by the user or admin password.

  • Redhat: redhat-config-date
  • Fedora and CentOS: system-config-date
  • Slackware and FreeBSD: tzselect

3. We can use up and down arrow keys to choose the geographic area in which the country is detected and hit the Enter button.

Linux Change Timezone

4. We can choose the region or city related to our time zone and hit the Enter button. It will modify the time zone on our system.

Linux Change Timezone

Technique 3: Using GUI in Ubuntu

1. Select an icon, i.e., "System Menu". It is a triangle (downward-facing) inside the upper-right side of our screen. Then, the drop-down menu would occur.

2. Press an icon, i.e., "Settings". This screwdriver and wrench-shaped icon is inside the lower-left side of a drop-down menu. But, in some distributions, this icon is will not be available. In that case, we can simply select the "Settings" option.

Linux Change Timezone

3. Select the Date & Time option. We will find this option over the left corner of the window.

Linux Change Timezone

Note: Ensure that our mouse is on the sidebar of the left hand when scrolling.

4. We need to turn off the Automatic Time Zone Select the blue switch, i.e., "Automatic Time Zone" in the page's middle to do so.

Note: Skip this process if the switch, i.e., "Automatic Time Zone" is grey.

Linux Change Timezone

5. Press Time Zone. It is close to the bottom side of the window. It will open the menu of Time Zone.

Linux Change Timezone

6. Choose a Time Zone. Select our approximate location over the world map for doing so. We should check the time modification for matching the chosen time zone of the area.

Linux Change Timezone

7. We will then need to close that window. It will save our settings and also accordingly update our time zone.

Linux Change Timezone

Technique 4: Using GUI in Mint

  1. In this section, we need to open the menu. Press Menu within the bottom-left side of the screen.
  2. Press on an icon, i.e., System Settings. It is composed of two grey cogs. We will find it over the Menu window's left side.
  3. Press on the Date & Time option. We will find it inside the group of options, i.e., "Preferences".
  4. Press Unlock. We will find it over the window's right side.
  5. We will need to type our user password when asked. Enter inside the password that we use for logging into our system.
  6. Press Authenticate. It is at the bottom side of the prompt. After doing this step, it will unlock the menu of Date & Time.
  7. Choose a time zone. Press on the map's vertical slice for picking the time zone. We should check the clock over the page's right side immediately modify it to reflect the chosen time of the time zone.
  8. Press Lock. It is on the window's right side. It will save the preferences of our time zone and lock the menu, i.e., Date & Time.

Tips:

  • On a few versions of Linux Ubuntu, Debian, SuSE, Gentoo, Slackware, and anyone else which is "normal", the command for displaying and changing the time zone is not the "clock" command, it is the "date" command.
  • On mobiles and other devices that execute Linux, the time zone is differently stored. It is described inside the /etc/TZ file. Manually, we can edit this file or apply the echo command (for example, echo GMT0BST > /etc/TZ for setting the United Kingdom's time zone).

Warnings:

  • A few applications (like PHP) contain separate settings of the time zone from the time zone of the system.
  • On a few systems, there's a system utility given that will ask for an accurate time zone and make the right modifications to the system configuration. For instance, Debian gives the "tzconfig" and "tzsetup" utility.

Next TopicLinux Load Average





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA