Every computing device has time and date as the very basic service provided by them. Date/time and time zone are interlinked phenomena in computing devices as date/time depends on the time zone selected by the user. The date and time are automatically fetched according to the time zone; however, the users can also change them manually.
The Linux computer manages two types of clocks:
It is also known as Real-Time Clock (RTC) and keeps on tracking the time and date even if the system is turned off. There is a small battery backup available for RTC that enables it to keep on running the clock.
Contrary to RTC, this clock has no power back up; thus, it does not keep the time when the system is powered off or on low power. However, when the system is turned ON, it gets help from the hardware clock and fetches the correct date/time. A software clock can also be referred to as a system clock.
In this article, we will provide a detailed usage of a well-known timedatectl command; so, let’s start:
How to check and edit time/date on Ubuntu 20.04
This section explains the process of checking and editing the time/date on Ubuntu 20.04.
The syntax timedatectl command is given below:
How to check current time and date using timedatectl
The primary use of this command is to show you current date and time; execute the command mentioned below to get the print of time and date:
After getting the result of the above command; you may notice detailed information such as your local time and date, universal time, time zone, etc.:
How to Change the time or date using timedatectl
The timedatectl command can be used to change the time or date of the system. To change the date or time, following syntax is used:
Moreover, the following command will change the local time to 11:11:11(HH:MM:SS); it is observed that the universal time and RTC are also adjusted according to local time:
To verify the changes, you must execute the following command:
Similarly, one can change the current date of the system using the same command as above:
The syntax to change the date of the system is given below:
Where “Y”, “M” and “D” represent the year, month, and day respectively.
For instance, the command given below changes the date to 2022-09-01(YYY-MM-DD): it is noted that time will also be reset to 00:00:00 :
How to Change the time zone using timedatectl
Firstly, you must know the time zone in which you are operating; you can check your time zone using the following command:
Or simple timedatectl command can also give you the required result, as shown in the screenshot below:
The timedatectl can be used to change the current time zone; firstly, you must know the time zones supported by your system; to check the list of available time zones, execute the following command.
In case you want to change the time zone to other available time zones, the above list would be helpful to you in this regard. You can set the timezone by following the syntax described below:
For instance, the following command will help to change the time zone to “America/Barbados”:
Moreover, if you want to set the time zone to Coordinated Universal Time (UTC), then execute the command given below: it is recommended to keep the settings of the clock in UTC:
How to Synchronize Real Time Clock using timedatectl
The hardware clock (also known as a real-time clock) of the system can be synchronized with your local time zone or UTC, using the timedatectl command. It passes binary numbers (0,1) to the command, which refers to the local time zone or UTC.
The binary number (0) is used to sync the hardware clock with the local time zone, and you can execute the following command to synchronize the Real-Time Clock to UTC:
Alternatively, you can synchronize RTC to the local time zone by using the command given below. This command will show the warning that changing the RTC to a local time zone can cause problems.
Referring to the syntax of timedatectl, it contains option keywords between timedatectl and command keywords. The timedatectl supports various options that can be considered to perform specific tasks, such as:
–h shows the help information
To check the version of the timedatectl; —version option is used.
—no–ask–password option will allow the user to bypass the authentication process
Ubuntu being the famous distro of Linux, allows a variety of commands to perform several operations. Among them, the timedatectl command is used to facilitate the command line users regarding the time zone, date, and time of your system. This guide provides brief information related to the timedatectl command of Ubuntu. The users can edit time, date, and time zone using the command line terminal. Moreover, it allows synchronization of the Real-Time Clock with local time zone or UTC, but it is better to practice keeping the RTC synchronized with UTC.