A time zone is identified based on the geographic region with the same standard time and date. Typically, the date, time, and time zone are set during the installation of an operational system. Users need to change the time zone for performing a few tasks in Linux platforms. Some jobs in Linux use time zone like cron jobs use it for execution or in logs timestamps. In this tutorial, we will go through different ways of changing the date, time, and time zone in Linux Mint 20 and Ubuntu 20.04.
To have the correct date and time in any operating system is very important since many operations depend on the date and time feature. To set a date, time in Linux Mint, open up the terminal either using the Ctrl+Shift+T shortcut or access it via ApplicationsTerminal.
Change date in Linux from the command line
In Linux platforms, the server and the clock of the system need to be exactly on time. You need to have sudo rights privilege to make such changes in your computer system. To proceed, type the following command in the terminal window:
$ date +%Y%m%d -s "YYYYMMDD"
The output will appear as shown in the figure below and the date will be set based on the input value.
Check the updated date and time from command line
To check the updated time from the command line, simply type
$ date
The output will display the updated time field.
timedatectl is a utility of Linux that allows users to view the system’s time and date through the terminal. To view the current time, date and time zone, use:
$ timedatectl
Change time in Linux from the command line
Users can also change the time from the command line by using
$ date +%T -s "hh:mm:ss"
Here we have set the time to 15:14:00 and once we press <enter> the output will appear as shown below. The time will be updated accordingly.
Change date and time with one command on Ubuntu
Linux allows users to update date and time through one single command as well. To update date and time through the one common command, type the following:
$ date -s "DD MM YYYY hh:mm:ss"
Where,
11: Hour (hh)
14: Minute (mm)
00: Second (ss)
As soon as you hit the <enter> key, the output will appear indicating that the date and time are updated accordingly.
Set hardware clock in Linux
A hardware clock runs within the hardware of your computer system even if there is no power supply still it continues to function. To check out the hardware clock use the following command:
$ hwclock --show
The output will appear as shown in the figure below, displaying the time of the hardware clock.
Now let’s check out the method that is used to set the hardware clock to the local time in a Linux system. For that, you will need to type:
$ hwclock --set --date="YYYY-MM-DD 16:45:05" --localtime
The hardware clock will be adjusted according to the local time.
Change the time zone through the command line
In order to change the time zone. First, let’s view the time zone of the system using timedatectl.
$ timedatectl
The system time zone in a Linux Mint system is configured by symlinking which is a /etc/localtime file. It is further configured to the binary time zone identifier that exists in the /usr/share/zoneinfo directory.
Another way by which, users can check the available time zone by using:
$ ls -l /etc/localtime
The output will look like this:
List of available time zones
To change the time zone, at first you need to find out and know the name of that time zone which you plan to use. Typically, the time zone in any system follows the “Region/City” format. Let’s view all available options.long name of the time zone you want to use:
$ timedatectl list-timezones
The output will show a list similar to the one displayed below:
Now, you can use any of the option from the list to update the time zone. Use the following command:
$ sudo timedatectl set-timezone <your_time_zone>
Here, in the example the time zone used by us is America/New_York. You can adjust the time zone as per your requirements following the same method.
Change the date, time, and time zone through GUI
To change the date, time and time zone through the UI method in Linux Mint 20, simply access the date and time shortcut on the bottom right of the screen and click on it. A calendar menu will open up, click on the Date and Time Settings option available at the bottom of the calendar.
You will see the Manually set date and Time option. Click on the date option against the Manually set date and time field.
A Select a Date modal will appear, you need to select a date then press the OK button to confirm the selection.
To change the time, select the Time option against the Manually set date and time in the Date & Time menu.
A modal will appear as shown in the figure below, update the time then select OK to reflect changes.
To update the time zone, click on Region in date and time modal.
You will see a list of Regions available, select the region first. It will show possible cities for that selected region. You need to select a city to proceed, once done select OK to make changes.
Conclusion
The methods discussed in this tutorial, tell the ways to change the date, time, and time zone in Linux Mint 20. Users can change them either through the command line or through the UI based on their preference. Both methods are easy to implement and explained in detail in this tutorial with examples.