Updating Timezone on Ubuntu Server: A Step-by-Step Guide from Terminal

Updating Timezone on Ubuntu Server: A Step-by-Step Guide from Terminal

Timezone on Ubuntu Server


Maintaining the correct time on a server is crucial for various reasons, including logging, scheduling tasks, and ensuring accurate data time-stamping. The timezone settings on a server are responsible for determining the correct time, and it's important to keep it updated. In this guide, we will be walking you through the process of updating the timezone on an Ubuntu server(supported in 16.04, 18.04, 20.04 and 22.04 ubuntu servers) from the terminal. Whether you're a system administrator or a developer, this guide will be of great help to you in managing your server's time accurately. The process is simple, straightforward, and can be completed in just a few steps. So, let's get started!


Step 1: Check the Current Timezone

Before we change the timezone, let's check the current timezone of the server. You can check it using the following command once you SSH to your server backend:

$ timedatectl

The output will display the current time, date, and timezone. Please see an example below

timedatectl result

The server is currently set to UTC timezone.


Step 2: List Available Timezones

Ubuntu provides a list of available timezones that you can choose from. You can list all the available timezones using the following command:

$ timedatectl list-timezones

This will display a list of all available timezones, which are organized by regions.

timedatectl list-timezones result

You can use grep command in combination with timedatectl to filter the timezones otherwise it would be difficult to locate specific timezone. Please see an example below.

timedatectl list-timezones with grep command


To exit from list, just press CTRL+C.


Step 3: Set the Timezone

To set the timezone, you need to use the following command:

$ sudo timedatectl set-timezone [timezone]

Replace [timezone] with the desired timezone, for example, America/New_York.

how to set timezone


Step 4: Verify the Changes

After you have set the timezone, you can verify the changes by running the following command:

$ timedatectl

The output should display the updated time, date, and timezone. The time zone and system clock synchronized values show that the new local time was updated successfully.


Conclusion

In conclusion, changing the timezone on an Ubuntu server from the terminal is a straightforward process. You can check the current timezone, list the available timezones, set the desired timezone, and verify the changes with a few simple commands. It's always a good practice to regularly check and update the timezone to ensure the accurate timekeeping on your server.


Comments