How to Change Ubuntu Server Time Zone via CLI?
Changing the time zone on an Ubuntu server ensures that your system
logs, cron jobs, and applications use the correct local time. This guide
provides a quick, step-by-step walkthrough on how to check your current
time zone, view available time zones, and update your system
configuration using the timedatectl command-line
utility.
Step 1: Check the Current Time Zone
Before making any changes, it is helpful to verify the current time and date settings of your server. You can display this information by running the following command:
timedatectlThe output will show your local time, universal time (UTC), and the
currently configured time zone (for example,
Time zone: Etc/UTC).
Step 2: List Available Time Zones
Ubuntu organizes time zones using a “Region/City” format. To find the exact name of the time zone you want to switch to, you can list all available options:
timedatectl list-timezonesBecause this list is extensive, you can filter the results using the
grep command to find a specific region, such as
America:
timedatectl list-timezones | grep AmericaStep 3: Set the New Time Zone
Once you have identified the correct time zone identifier from the
list, use the set-timezone argument followed by your chosen
zone. Note that you will need administrative privileges
(sudo) to execute this change:
sudo timedatectl set-timezone America/New_YorkReplace America/New_York with the specific time zone
appropriate for your region.
Step 4: Verify the Changes
To confirm that the update was applied successfully, run the status command once more:
timedatectlCheck the Time zone: line in the output to ensure it
matches your new selection and that the local time has adjusted
accordingly.