Are you trying to change the Date, Time, and Timezone in Ubuntu ?
This guide is for you.
All the modern operating systems that we use today are synchronized with NIST atomic clock. Therefore, we generally do not find any need of changing the date, time, and Timezone of our systems.
However, at times it happens that we may mess up these features while performing some system configurations and we may feel the need of manually changing these entities later on.
Here at LinuxAPT, as part of our Server management Services, we regularly help our Customers to perform Ubuntu related queries.
In this context, we shall look into the different methods to modify the date, time, and Timezone in Ubuntu 20.04.
To modify the date, time, and Timezone in Ubuntu 20.04, you can follow the methods that we have described below.
However, before proceeding with these methods, we would first like to take a look at the current date, time, and Timezone of our Ubuntu 20.04 system.
These entities can be found out by running the following command:
$ timedatectl
This command will display the current date, time, and Timezone along with some other information.
If the NTP Service is active, then you need to deactivate this feature otherwise your system should not be synchronized with the NIST atomic clock if you want to manually change the date, time, and Timezone.
To deactivate this feature, you have to run the following command:
$ timedatectl set-ntp no
Once deactivated successfully, you will not be able to see any error messages on the terminal in relation to NTP.
Next, let's see the methods to change the date, time, and Timezone of our Ubuntu 20.04 system.
To change the date in your Ubuntu 20.04 system, you have to run the following command:
$ timedatectl set-time YYYY-MM-DD
Here, you have to replace YYYY with your desired year such as 2021, MM with your desired month such as 01, and DD with your desired date such as 01.
The the command would be:
$ timedatectl set-time 2021-01-01
To check whether the date of our Ubuntu 20.04 system has been changed or not , simply execute the “timedatectl” command once again.
To modify the time in your Ubuntu 20.04 system, you have to run the following command:
$ timedatectl set-time hh-mm-ss
Here, you have to replace hh with your desired hours such as 10, mm with your desired minutes such as 10, and ss with your desired seconds such as 10.
Then the command to run would be:
$ timedatectl set-time 10-10-10
To confirm the changes made, you can run the "timedatectl" command once again.
To modify the Timezone in your Ubuntu 20.04 system, you first need to take a look at all the available Time zones in your Ubuntu 20.04 system by running the command shown below:
$ timedatectl list-timezones
This will display the list of all the available Time zones.
Out of all these Time zones, you can pick any one of your choice to change your system's Timezone.
Now you can change the Timezone by running the command shown below:
$ timedatectl set-timezone region/location
Here, you have to replace region and location with the exact name of the region and location of the Timezone that you have selected from the list of the available Time zones such as Australia and Adelaide.
So the command would be:
$ timedatectl set-timezone Australia/Adelaide
Now we will check whether the Timezone of our Ubuntu 20.04 system has been changed or not by running the “timedatectl” command once again.
This article will guide you on the different methods to modify the date, time, and Timezone of your #Ubuntu 20.04 system.
However, if you have attempted to change these entities just for the sake of demonstration, then it is highly recommended to activate the #NTP Service again once you are done so that your system can again synchronize itself with NIST atomic clock.
This can be done by running the “timedatectl set-ntp yes” command.
To change the time zone in Linux systems use the sudo timedatectl set-timezone command followed by the long name of the time zone you want to set.
To change the hostname in #Linux:
1. Type the following command to edit /etc/hostname using nano or vi text editor: sudo nano /etc/hostname. Delete the old name and setup new name.
2. Next Edit the /etc/hosts file: sudo nano /etc/hosts.
3. Reboot the system to changes take effect: sudo reboot.
#NTP server sync date and time in Linux by:
i. On the Linux machine, log in as root.
ii. Run the ntpdate -u <ntpserver> command to update the machine clock. For example, ntpdate -u ntp-time.
iii. Open the /etc/ntp. conf file and add the NTP servers used in your environment.
iv. Run the service ntpd start command to start the NTP service and implement you configuration changes.