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.
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.
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.
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.
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.
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.
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:
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:
This command should be followed by the user or admin password.
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.
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.
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.
3. Select the Date & Time option. We will find this option over the left corner of the window.
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.
5. Press Time Zone. It is close to the bottom side of the window. It will open the menu of Time Zone.
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.
7. We will then need to close that window. It will save our settings and also accordingly update our time zone.
Technique 4: Using GUI in Mint