Set and synchronize system time using time servers

Context: LFCS certification

Set and synchronize system time using time servers

To set and synchronize the system time using time servers in preparation for the Linux Foundation Certified System Administrator (LFCS) certification, you can follow these steps:

  1. Choose a Time Server:

    • Identify a reliable time server to synchronize your system time. Popular time servers include NTP (Network Time Protocol) servers.
  2. Install NTP:

    • Ensure the NTP package is installed on your Linux system. If it's not already installed, you can install it using the package manager of your distribution.
    • For example, on Ubuntu or Debian-based systems, you can use the following command:
      sudo apt-get install ntp
    • On CentOS or Red Hat-based systems, you can use the following command:
      sudo yum install ntp
  3. Configure NTP:

    • Open the NTP configuration file, usually located at /etc/ntp.conf, using a text editor with root privileges.
    • Locate the line that starts with "server" followed by the default time servers.
    • Comment out or remove the default time servers and add the address or domain name of your preferred time server(s).
    • For example:
      server time.example.com
  4. Save the Configuration and Restart NTP:

    • Save the changes made to the NTP configuration file and exit the text editor.
    • Restart the NTP service to apply the new configuration.
    • On Ubuntu or Debian-based systems, use the following command:
      sudo service ntp restart
    • On CentOS or Red Hat-based systems, use the following command:
      sudo systemctl restart ntpd
  5. Verify Time Synchronization:

    • Monitor the system time synchronization by checking the logs or using the ntpq command to query the NTP daemon.
    • For example, use the following command to check the peers and their synchronization status:
      ntpq -p

By following these steps, you can set and synchronize the system time using time servers. It's important to ensure accurate time synchronization for various system processes, event logging, and maintaining consistency across the network. Remember to review the NTP documentation specific to your Linux distribution for any additional configuration options or variations in the setup process.

You should also read: