The correct time zone setting on Ubuntu 24.04 is crucial for displaying accurate local time, which affects various system tasks. These tasks include clock synchronization across different regions, scheduling processes, and the proper functioning of the cron
daemon for executing scheduled jobs. This guide explores several methods to adjust the time zone on Ubuntu 24.04.
Changing Time Zone Through Graphical User Interface
The most user-friendly way to change the time zone is through the system settings, as it doesn’t require any command-line interaction.
Step 1: Navigate to the system settings.
Step 2: Go to Date & Time
settings.
Step 3: Click on the Time Zone
option and select your desired location.
Step 4: Once you’ve selected the time zone, it will be displayed.
Alternatively, you can enable the Automatic Time Zone
feature, which automatically adjusts the time zone when connected to the internet.
Changing Time Zone Through Command Line
Ubuntu and other Linux distributions are frequently managed via the command line interface. Here are command-line methods for changing the time zone.
Using timedatectl
Command
The timedatectl
utility, pre-installed on Ubuntu, manages time, date, and time zone settings.
Step 1: Check the current timezone.
timedatectl
Step 2: List all available time zones in Ubuntu 24.04 to find your desired one.
timedatectl list-timezones
Step 3: To narrow down the list, use grep
to search for a specific time zone by keyword.
timedatectl list-timezones | grep -i <timezone-keyword>
For example, to search for London:
timedatectl list-timezones | grep -i London
Step 4: Once you’ve found the desired timezone, use the set-timezone
command to set it.
sudo timedatectl set-timezone <desired-timezone>
Step 5: Verify the change by running the timedatectl
command again.
timedatectl
Using tzdata
Package
Another way to set the timezone in Ubuntu is by using the time zone database package. This package contains historical and current data for various time zones.
Step 1: Reconfigure the timezone data using the following command.
sudo dpkg-reconfigure tzdata
Step 2: Select your geographic area when prompted and press Ok
.
Step 3: Next, select the city or region corresponding to your time zone and press Ok
.
Once selected, the changes will be applied automatically.
The primary difference between timedatectl
and tzdata
is that timedatectl
is a utility for managing system time and date settings, while tzdata
contains the files documenting time zone transitions. timedatectl
indirectly depends on tzdata
for managing time and date.
Using tzselect
Menu
tzselect
is a utility that helps users select a suitable time zone.
Step 1: Start the process by executing the following command.
tzselect
Step 2: Follow the prompts to select your continent, country, and then a specific time zone.
Step 3: At the end, a verification prompt will appear. After reviewing the changes, choose yes
to proceed.
These changes are temporary and will revert upon reboot or shell restart. To make them permanent:
Step 4: Save the selected time zone to your .profile
file. Replace America/Detroit
with your chosen time zone.
echo "TZ='America/Detroit'; export TZ" >> ~/.profile
Using Symlink File for Local Time
Symbolic links in Ubuntu link libraries/executables, ensuring consistent file locations and simplifying access to files in complex directories.
Step 1: Remove the existing localtime
symbolic link.
sudo rm -rf /etc/localtime
Step 2: Create a new symbolic link from the specified time zone to the localtime
file. Replace <add-time-zone>
with your desired time zone path.
sudo ln -s /usr/share/zoneinfo/<add-time-zone> /etc/localtime
Step 3: Verify the changes by checking the information in the created symbolic link.
ls -l /etc/localtime
Setting the correct time zone in Ubuntu is crucial for the proper operation of scheduled tasks and other time-sensitive system functions. By using either the graphical interface or one of the command-line utilities, you can ensure that your system clock is accurately synchronized with your local time.