The system timezone in Ubuntu is initially configured during installation, usually based on the system's geographical location. This setting ensures smooth operation of time-dependent services, including cron jobs.
Ubuntu manages the system timezone through the /etc/localtime file, which is a symbolic link to a timezone data file located in the /usr/share/zoneinfo directory. Changing the timezone involves updating this symbolic link to the appropriate timezone file.
The timedatectl command is typically used to modify the system timezone on an Ubuntu server or desktop. This command allows users to check the current timezone, list all available timezones, and easily set a new timezone. Alternatively, users can directly manipulate the symbolic link in /etc/localtime to point to a different timezone file in /usr/share/zoneinfo. The timedatectl command is preferred for its simplicity and ease of use.
Steps to change system timezone in Linux:
- Launch the terminal.
- Check the currently used timezone using timedatectl.
$ timedatectl Local time: Mon 2024-05-06 19:06:41 +08 Universal time: Mon 2024-05-06 11:06:41 UTC RTC time: Mon 2024-05-06 11:06:42 Time zone: Asia/Kuala_Lumpur (+08, +0800) System clock synchronized: no NTP service: active RTC in local TZ: no
- List available timezones in the system using timedatectl.
$ timedatectl list-timezones Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara Africa/Asmera Africa/Bamako Africa/Bangui Africa/Banjul Africa/Bissau Africa/Blantyre Africa/Brazzaville Africa/Bujumbura Africa/Cairo Africa/Casablanca Africa/Ceuta Africa/Conakry Africa/Dakar Africa/Dar_es_Salaam Africa/Djibouti ##### snipped
- Search for your timezone from the list of available timezones.
$ timedatectl list-timezones | grep -i tokyo Asia/Tokyo
- Set the new timezone using timedatectl.
$ sudo timedatectl set-timezone Asia/Tokyo [sudo] password for user:
The above command is similar to doing the following two manual steps:
- Unlink your currently-used timezone.
$ sudo unlink /etc/localtime [sudo] password for user:
- Link /etc/localtime to your new timezone.
$ sudo ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
- Confirm the changes using timedatectl.
$ timedatectl Local time: Mon 2024-05-06 20:09:09 JST Universal time: Mon 2024-05-06 11:09:09 UTC RTC time: Mon 2024-05-06 11:09:10 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: no NTP service: active RTC in local TZ: no
This guide is tested on Ubuntu:
Version | Code Name |
---|---|
22.04 LTS | Jammy Jellyfish |
23.10 | Mantic Minotaur |
24.04 LTS | Noble Numbat |
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.