Ubuntu

How To Set or Change Timezone on Ubuntu 24.04

timezon in ubuntu 24.04

The primary objective of the timezone in Ubuntu 24.04 or any other Linux distribution is to display the accurate local time based on the system location. The timezone adjustment holds a significant value as based on the local time the execution of various tasks depends.

These tasks include clock synchronization of different regions, task scheduling, and running of the cron daemon responsible for executing scheduled tasks. On Ubuntu 24.04, the timezone can be adjusted in various ways which will be discussed in this guide.

Outline:

How to Set or Change the Time Zone in Ubuntu 24.04

If you are installing Ubuntu 24.04 on your system then as a part of the installation process you will be asked about setting the timezone. For that either drag the location pin to the desired location or search for the location and timezone in the search bar:

Now if you want to change the timezone after the installation then there are two primary ways one is through using the four different commands in the command line interface. The other one is by navigating to date and time settings.

1: Through Command Line

Ubuntu and other Linux distributions are primarily managed and used through their command line interface. For that one has to have a sound knowledge of task executions using various commands.

1.1: Using timedatectl command

The timedatectl is a utility that is pre-installed on Ubuntu which is primarily used for managing the time, date, and time zone on your Linux system. So to either set or to change the time zone in Ubuntu you first need to see what is the current timezone and for that execute:

timedatectl

Now as in the image, the time zone for New York is selected, so to change it first sort out you desired timezone which you want to set and for that list all the available timezones in Ubuntu 24.04:

timedatectl list-timezones

Now the list is quite long which makes it tiring to pick the suitable timezone so to avoid that you can enter the keywords of the desired time zone by using the grep command:

timedatectl list-timezones | grep -i <timezone-keyword>

Now here for illustration, I have searched for London and the filter result shows Europe/London:

Once you have selected the timezone, then use the set-timezone command along with desired timezone and city name:

sudo timedatectl set-timezone <enter-desired-timezone>

Further, after setting the desired timezone, verify it by executing the timedatectl command:

1.2: Using tzdata Package

Another way to set or change the timezone in Ubuntu is by using the time zone database package which contains the record of the previous and current transitions for various time zones. To use this package for setting the time zone execute the below command to reconfigure the timezone data:

sudo dpkg-reconfigure tzdata

Now first it will ask about the current geographic area so here select the area in which you are living and click on Ok:

Next, it will ask about the city or region in which you are residing, the city or region choice must correspond to the time zone of your area:

Once you have selected the city or region, the changes will appear upon the completion of the task:

The primary difference between timedatectl and tzdata utilities is that timedatectl command can only be used to manage system time and date settings. Whereas the tzdata package contains the files documenting time zone transitions and not only that the timedatectl somehow depends on it for managing time and date indirectly.

1.3: Using tzselect Menu

Another built-in utility for changing the time zone in Ubuntu is tzselect whose prime purpose is to help users while selecting the suitable time zone for their Ubuntu 24.04. To simply start the process execute:

tzselect

Now as in the image above prompt about the location of the system will appear at first so select the location based on the continent. Then a list of countries in the next prompt will appear related to that selected continent:

Now here I have selected the country on the number 49 and afterward, another prompt will appear asking to choose a suitable time zone:

Now once the process is completed at the end a verification prompt will appear so after reviewing the changes select for yes to proceed:

Now these changes are not permanent as the timezone will revert once the system is rebooted or the shell session is restarted as stated in the image below:

To make the changes permanent you need to save the following time zone you selected to the profile file by executing:

echo "TZ='America/Detroit'; export TZ" >> ~/.profile

1.4: Using Symlink File for Local Time

Symbolic links in Ubuntu are used to link libraries/executables while keeping the original files are in consistent places. Further, it makes the access of files easy which are placed in complex directories. So to set or change the time zone of Ubuntu you can use the symbolic link for the local time file, first, you have to remove it and for that execute:

sudo rm -rf /etc/localtime

Next, create a symbolic link from the specified time zone to the local time file:

sudo ln -s /usr/share/zoneinfo/<add-time-zone> /etc/localtime

Next, verify the changes check the information in the symbolic link created in the previous command:

ls -l /etc/localtime

2: Through Graphical User Interface

The most convenient way to change the time zone in Ubuntu is by going into system settings, as it requires no command execution whatsoever. To change or to set the timezone in Ubuntu navigate to the system settings and from there go to date and time settings:

Now click on the Time Zone option and select the desired location:

Once you have selected the time zone it will appear in the option, on the contrary, you can turn on the Automatic Time Zone feature as it automatically adjusts when connected to the internet:

Conclusion

Setting the time zone in Ubuntu and other Linux distributions is necessary because the cron daemon schedules and executes the tasks at specific times. So if the time zone is incorrect, then scheduled tasks might run at unexpected times. To set or change the time zone in Ubuntu there are two main methods one is by using four different utilities which include timedatectl, tzdata, tzselect, and creating a symbolic link for the time zone. The other method is to change the time zone settings in the Date & Time settings under the system settings.

 

Similar Posts