Featured image of post Updating Time Zone on Ubuntu System

Updating Time Zone on Ubuntu System

Introduction: The default time for Ubuntu systems is UTC. If you need to change the system time to a different time zone, you can follow these steps: ...

Introduction

Ubuntu systems use UTC as the default time zone. If you need to set the system time to a different time zone, you can follow the steps below:

Step 1: Check Current Time Zone

Open the terminal and enter the following command to check the current system time zone:

1
timedatectl

The output will look something like this:

1
2
3
4
5
6
7
8
|  | Local time:      Thu 2023-11-16 17:22:23 CST |
| --- | --- |
|  | Universal time:  Thu 2023-11-16 09:22:23 UTC |
|  | RTC time:        Thu 2023-11-16 09:22:23 UTC |
|  | Time zone:       Asia/Shanghai (CST) |
|  | System clock:    x86_64 |
|  | NTP enabled:    yes |
|  | NTP synchronized: yes |

The line that starts with Time zone: shows the current system time zone. For example, it shows Asia/Shanghai (CST), which is the time zone for Shanghai, China.

Step 2: Choose Target Time Zone

You can select the target time zone using one of the following two methods:

  1. Using the tzselect command
1
sudo tzselect

This command will launch an interactive interface to guide you in selecting the desired time zone.

  1. Directly specifying the time zone name

If you know the name of the target time zone, you can use the following command to set it as the system time zone:

1
sudo timedatectl set-timezone <TimeZoneName>

For example, to set the system time zone to New York, USA:

1
sudo timedatectl set-timezone America/New_York

Step 3: Update System Time

After setting the time zone, you need to update the system time to align with the new time zone. Use the following command to update the system time:

1
sudo ntpdate ntp.ubuntu.com

This command will synchronize the time with the NTP server.

Step 4 (Optional): Modify Hardware Time

If you want to maintain the correct time even when the system is shut down, you should modify the hardware time. You can do this using the following command:

1
sudo hwclock --systohc

This command writes the system time to the hardware clock.

Verification

Once you have completed the above steps, you can again use the timedatectl command to check the current system time zone and time, confirming that the update was successful.

Notes

  • Changing the system time zone may affect certain applications, especially those that rely on scheduled tasks.
  • Modifying the hardware time may result in system startup issues, so please proceed with caution.
Licensed under CC BY-NC-SA 4.0