Change time zone in Ubuntu
Each server in a public or private network provides different services. Therefore, this server must be properly configured to work with high efficiency. A system’s configuration includes complex and technical items such as resource management and simpler items such as time and date settings. In this article, we will do just that. That is, learning how to change the time zone in Ubuntu.
Even if the time zone in your Ubuntu is correct, it is better to learn how to change it to increase your expertise. For example, sometimes, you need to change the time zone of your Ubuntu-based VPS to do a certain task.
Change the Timezone in Ubuntu in 2 ways.
Changing the time zone of Linux servers is one of the most important steps in their configuration. If the Timezone is improperly configured on your server, it will primarily affect three things—login, Automation, and Cronjobs.
Many Sysadmins use tools to automate the execution and updating of programs. A bad configuration time will cause the application to not start at the right time. Similarly, the timing of backups and other tasks can also be affected.
Another thing to remember is that if the server uses NTP, this error can multiply in different nodes or nodes of the network. So as we can see, this issue should be taken seriously. Learning how to change the time zone in Ubuntu may not seem like a big deal to you, but it can have a big impact on your system.
Before making any changes, we must first connect to our server using SSH. If you don’t know how to do this, read the tutorial on connecting to a virtual server using SSH in PuTTY software.
There are different ways to do this. In this post, we will use to select and timedatectl methods.
How to change time zone in Ubuntu using tzselect
In Debian-based distributions such as Ubuntu, Linux Mint or ElementaryOS, it is possible to use the tzselect command. A command from Linux that allows us to change the time zone with a command line interface.
First, enter the following command in the terminal:
When running the command, the terminal will show us a list of geographic regions that we should choose according to our needs. For example, if we select America, we can see the list of available time zones for that region. After entering the command, enter the numerical value displayed next to each field.
Once you’re done, you can check if the change was successful by entering the following command at the command prompt:
It was done so easily.
How to change time zone in Ubuntu using timedatectl
The next command that allows us to change the Timezone in Ubuntu is timedatectl. This command is more complete than the previous command because it also provides the possibility to change other things such as date and system time.
First, let’s see what time zones are available:
As we can see there are many areas. You can press CTRL+C to exit this screen. However, we can combine the above command with the grep command to filter the search using the city name as the criteria. For example:
timedatectl list-timezones | grep Bushehr
Once we are sure which time zone we want to choose, we need to use the following command to make the change:
sudo timedatectl set-timezone [timezone]
Finally, we can see the applied change using the following command:
Knowing how to change the time zone in Ubuntu is a simple yet important task for properly configuring your server. This becomes even more important if the server uses NTP to synchronize the time of network devices. Also, remember that misconfiguring time zones can lead to problems when scheduling backups, etc.
In this educational article, we learned how to change time zones in Ubuntu using two methods, tzselect and timedatectl.
We suggest you follow the educational posts on our blog to increase your knowledge and skills.