Access to a server using root
or a user who has sudo
privileges.
Check Current Timezone
Also, read Running Jenkins in Kubernetes Cluster with Persistent Volume
To check the configured time zone that your server uses currently, you can use the following command on your Ubuntu 22.04 machine.
timedatectl
You will get an output similar to the one below.
Output
Local time: Mon 2022-05-23 01:50:57 UTC
Universal time: Mon 2022-05-23 01:50:57 UTC
RTC time: Mon 2022-05-23 01:50:57
Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
Now the time zone configured is UTC.
The system timezone is configured by creating a symbolic link of /etc/localtime
to a binary timezone identifier in the /usr/share/zoneinfo
directory.
You can also view the timezone by viewing the timezone
file created inside the etc
directory.
cat /etc/timezone
Output
Etc/UTC
Change Timezone in Ubuntu
Now you can proceed to change the default timezone to your location. The time zones in Ubuntu uses the “Region/City” format.
So, you need to find your region and city using the list-timezones
option with the timedatectl
command.
timedatectl list-timezones
This command outputs all the available time zones.
Output
Africa/Abidjan
Africa/Accra
Africa/Algiers
Africa/Bissau
Africa/Cairo
. . .
Press Enter
to load additional available time zones.
Once you have found your time zone you use the below format to set up your own time zone.
sudo timedatectl set-timezone your_time_zone
If your time zone is America/Los_Angeles, your format should be like this
sudo timedatectl set-timezone America/Chicago
Now you can again use the timedatectl
command to confirm the time zone update.
Output
Local time: Sun 2022-05-22 20:53:00 CDT
Universal time: Mon 2022-05-23 01:53:00 UTC
RTC time: Mon 2022-05-23 01:53:00
Time zone: America/Chicago (CDT, -0500)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
That’s all.
Conclusion
Now you have learned how to change the time zone in your Ubuntu 22.04 machine.
Thanks for your time. If you face any problems or any feedback, please leave a comment below.