This article was first published in: https://www.itcoder.tech/posts/how-to-set-or-change-timezone-on-ubuntu-20-04/
Using the correct time zone is essential for system-related tasks and processes. For example, the cron daemon uses the system time zone to perform timing tasks, and the timestamp in the log is also based on the same system time zone.
On Ubuntu, the system time zone is usually set during installation, but it can be easily modified later.
This article describes how to use the command line or GUI interface to set or modify the time zone on Ubuntu 20.04.
Set or modify the system time zone as root or another sudo user.
timedatectl
is a command line tool, which allows you to view or modify the system time and date. It can be used in all modern System-based Linux systems, including Ubuntu 20.04.
To print the current system time zone, run timedatectl
without parameters.
timedatectl
The following output shows that the system time zone is set to "UTC":
Local time: Wed 2020-05-0619:33:20 UTC
Universal time: Wed 2020-05-0619:33:20 UTC
RTC time: Wed 2020-05-0619:33:22
Time zone:UTC(UTC,+0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
The system time zone is configured through the link file /etc/localtime
, which points to a binary time zone identification file in the /usr/share/zoneinfo
directory. Another way to check the time zone is to display the actual path the linked file points to, using the ls
command:
ls -l /etc/localtime
lrwxrwxrwx 1 root root 27 Dec 1012:59/etc/localtime ->/usr/share/zoneinfo/Etc/UTC
The time zone of the system is also written into the /etc/timezone
file:
cat /etc/timezone
UTC
timedatectl
command to modify the time zone##When changing the time zone, you will need to find a long name for the time zone you want to use. The time zone usually uses the "region/city" format.
To list all available time zones, you can list all files in the /usr/share/zoneinfo
directory, or run the timedatectl
command with the list-timezones
option:
timedatectl list-timezones
...
America/Montevideo
America/Nassau
America/New_York
America/Nipigon
America/Nome
America/Noronha
...
Once you have identified which time zone is ready to describe your location, as root or another user with sudo privileges, run the following command:
sudo timedatectl set-timezone your_time_zone
For example, if you want to set the system time zone to America/New_York
:
sudo timedatectl set-timezone America/New_York
Run the timedatectl
command to verify the modification:
timedatectl
Local time: Wed 2020-05-0615:41:42 EDT
Universal time: Wed 2020-05-0619:41:42 UTC
RTC time: Wed 2020-05-0619:41:48
Time zone: America/New_York(EDT,-0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
If you are running Ubuntu desktop version, you can also modify the current system time zone through the GUI.
In the system settings window, click the Date & Time
tab. If Automatic Time Zone
is turned on, and you have an Internet connection and location services are also turned on, then your time zone should have been automatically set according to your location.
To select a new time zone, you need to click on the map or search for a time zone through the search bar.
Once done, click on the x
to close the window.
We have shown you how to change the time zone of your Ubuntu system.
If you have any questions, please contact us in the following ways:
WeChat: sn0wdr1am86
WeChat group: add the above WeChat, remark the WeChat group
QQ: 3217680847
QQ Group: 82695646
Recommended Posts