The system timezone in Ubuntu is set during installation and is typically based on your location. Proper configuration of the system timezone is essential for time-dependent services like cron jobs.
Ubuntu manages timezones through the /etc/localtime file, which links to the appropriate timezone data in the /usr/share/zoneinfo directory. To change the timezone, this symbolic link must be updated to point to the correct file.
The timedatectl command is the preferred tool for managing timezones on Ubuntu systems. It allows users to check the current timezone, list available timezones, and set a new one with ease.
Steps to change system timezone in Linux:
- Open the terminal.
- Check the current 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 all available timezones 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 the desired timezone.
$ 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 by checking the timezone again.
$ 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.