It is necessary that the date and time of your installed operating system must correct.
Many jobs like the cron tasks that are running in the background and log entries of your system consist of specific timestamps.
It is also helpful that the clock shows you the correct time when you are working on a desktop system.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform CentOS related queries.
In this context, we shall look into how you can adjust the date, time, and time zone of your CentOS 8 operating system.
The time, date, and time zone can be adjusted by using the following two different ways in CentOS 8:
1. Changing date, time, and time zone using the graphical interface
2. Changing date, time, and time zone by using the command-line / Terminal window
You can set the date, time, and time zone of your CentOS system using the graphical environment in the following steps:
i. Login into your CentOS system and click on the 'Activities' section from the top left corner of the desktop.
Now, click on the menu icon.
ii. Here, all application icons will be displayed on the desktop. Click on the 'setting' icon.
iii. Now, a window will show you on the screen. Click on the search icon from the displayed window's corner and type the word 'date and time' in the search bar.
iv. All relevant results will display in the left corner under the search bar.
Click on the date and time clock icon.
v. You will see a Window on the desktop. Here, click on the date and time option from all listed options.
vi. A dialog will display on the window where you can change the set the time and date according to your region timings. The '+' sign will plus or increase the time and the '-' sign will minimize or decrease it.
Select the 'month' and similarly, you can set date and year using their respective symbols.
When you click on the month, you will see a drop-down list where you can select the desired month.
To change the time zone, click on the 'time zone' from the Date & Time window.
A search bar at the top of the window will display, type the region that you want to set, and press 'Enter'.
The desired time zone will automatically set on your system after doing this specified action.
You can also adjust the time format of 24 hours in 'AM /PM' format. So, choose the 'Time Format' from the displayed list.
There is a command through which you can adjust your system date and time. Using the 'timedatectl' you can display and adjust the date and time of your system. Therefore, open the terminal from the left sidebar of your desktop after clicking on the 'Activities'.
By using the below-given command, you can view the current date, time of your operating system:
$ timedatectl
or
$ timedatectl status
To adjust the time of your system, type the following command on the terminal:
# timedatectl set-time 17:18:00
If you will get an error like the above. 'Failed to set time: NTP unit is active' then, by using the following command you will disable the NTP unit:
# timedatectl set-ntp false
Again, try to change the time of your system by running the following command and check the updated time:
# timedatectl set-time 17:18:00
Similarly, you can also adjust the date of your system.
# timedatectl set-time 2019-01-01
If you want to change both the date and time of your system at a time then, use the following command to adjust the date and time:
# timedatectl set-time '2021-03-25 16:18:45'
You can also set the time zone of your system using the command line. To view the list of all available time zones, type the following command:
# timedatectl list-timezones
To adjust the time zone of your system, type the following command on the terminal:
# timedatectl set-timezone Europe/Moscow
Here, you can replace 'Europe/Moscow' with your desired time zone.
This article covers how you can easily adjust the time, date, and time zone of your system in CentOS 8.
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.
How to Synchronize Time on Installed Linux Operating Systems ?
1. On the Linux machine, log in as root.
2. Run the ntpdate -u <ntpserver> command to update the machine clock. For example, ntpdate -u ntp-time.
3. Open the /etc/ntp. conf file and add the NTP servers used in your environment.
4. Run the service ntpd start command to start the NTP service and implement you configuration changes.
Importance of man command in Linux:
man command in Linux is used to display the user manual of any command that we can run on the terminal.
It provides a detailed view of the command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS.