How to Change the Time Zone in Ubuntu Server

How to Change the Time Zone in Ubuntu Server

Introduction

Setting the correct time zone on your Ubuntu system is essential for accurate timekeeping and ensuring that timestamps are consistent with your location. In this blog post, we will guide you through the process of changing the time zone on Ubuntu using the timedatectl command. Specifically, we'll demonstrate how to change the time zone to "Mountain Time" (GMT-7) as an example.

Step 1: Check Current Time Zone

Before changing the time zone, it's a good practice to check the current time zone setting on your Ubuntu system. Open a terminal and enter the following command:

timedatectl

This command will display information about the current time zone, among other details.

Step 2: List Available Time Zones

To change your time zone, you need to know the specific location within that zone. The timedatectl command provides a list of available time zones that you can explore. You can use grep along with that to filter your region:

timedatectl list-timezones | grep -i mountain

If you want just to display a comprehensive list of time zones, organized by region and city, don't use grep.

Step 3: Change the Time Zone

Now that you've identified your desired time zone, you can change it using the following command. Replace "America/Denver" with your chosen location:

sudo timedatectl set-timezone US/Mountain

Remember to use sudo for administrative privileges.

Step 4: Restart the systemd Service

To apply the changes, restart the systemd service:

sudo systemctl restart systemd-timesyncd

Step 5: Verify the Time Zone Change

To confirm that the time zone has been updated successfully, use the date command in the terminal. Enter the following command:

date

This command will display the current date and time according to the newly set time zone. Check to ensure that it reflects the new time zone you selected.

Conclusion

Changing the time zone on your Ubuntu system is a straightforward process using the timedatectl command. You can ensure that your system's time settings align with your local time zone, helping to maintain accurate timestamps and schedule tasks effectively.

Feel free to explore the extensive list of time zones provided by timedatectl to set your preferred time zone according to your location.