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:
|
|
The output will look something like this:
|
|
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:
- Using the
tzselect
command
|
|
This command will launch an interactive interface to guide you in selecting the desired time zone.
- 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:
|
|
For example, to set the system time zone to New York, USA:
|
|
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:
|
|
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:
|
|
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.