Using the Linux timedatectl command

      No Comments on Using the Linux timedatectl command

Introduction

The timedatectl utility is distributed as part of the systemd system and service manager.

It allows you to review and change the configuration of the system clock.

This tool can be used to change the current date and time, set the time zone or enable automatic synchronization of the system clock with a remote server.

To display current date and time along with detailed information about the configuration of the system and hardware clock, run the timedatectl command with no additional command line options:

To change the current time, we have to ensure automatic time synchronization is disabled. Type the following in the shell prompt as root to disable ntp

Next, we set the current time in the format HH:MM:SS.

Replace HH with an hour, MM with a minute, and SS with a second, all typed in two-digit form.

By default, the system is configured to use UTC. To configure your system to maintain the clock in the local time, run the timedatectl command with the set-local-rtc option as root:

To change the current date, type the following at a shell prompt as root:

Make sure to disable ntp before running the command.

Changing the date without specifying the current time results in setting the time to 00:00:00.

Therefore, to set the date to 14th March 2018 maintaining the current time as 18:33 hrs, run;

Working with timezones

With timedatectl, you can also view and change system timezones.

To list available timezones, run

To set current timezone to Africa/Nairobi run

Working with NTP

The timedatectl command also allows you to enable automatic synchronization of your system clock with a group of remote servers using the NTP protocol.

Enabling NTP enables the chronyd or ntpd service, depending on which of them is installed.

The NTP service can be enabled and disabled using a command as follows:

The command will fail if an NTP service is not installed. Make sure either chronyd or ntpd is installed.

 

The following two tabs change content below.

harun

Harun is a System Administrator with proficient knowledge in cloud technologies such as KVM, Cloudstack, Citrix Xen Server, Openstack and VMware Vsphere Suite, Ceph, NFS, ISCSI

Latest posts by harun (see all)

About harun

Harun is a System Administrator with proficient knowledge in cloud technologies such as KVM, Cloudstack, Citrix Xen Server, Openstack and VMware Vsphere Suite, Ceph, NFS, ISCSI

Leave a Reply

Your email address will not be published. Required fields are marked *