Software & AppsOperating SystemLinux

How To Update Time and Date from Internet on Ubuntu: Command and GUI Options

Ubuntu 5

Maintaining accurate system time is crucial for your Ubuntu system. It ensures that tasks and processes are correctly synchronized and logs are accurately timestamped. This article will guide you through the process of updating the time and date from the internet on Ubuntu, using both command line and GUI options.

Quick Answer

To update the time and date from the internet on Ubuntu, you can use the ntpdate command or the date and wget commands in the command line. Alternatively, you can use the graphical interface by opening the Settings application and navigating to Details > Date & Time. For more advanced time synchronization, you can install ntpd and configure it with preferred NTP servers.

Updating Time and Date via Command Line

Using the ntpdate command

One of the most straightforward methods to update time and date is by using the ntpdate command. This command queries a Network Time Protocol (NTP) server and adjusts your system time accordingly. Here’s how to use it:

sudo ntpdate time.nist.gov

In this command, sudo is used to execute the command with root privileges. ntpdate is the command that syncs the time with the NTP server, and time.nist.gov is the NTP server provided by the National Institute of Standards and Technology.

If you encounter the error “ntpdate: command not found”, you may need to install the ntpdate package. You can do this by running:

sudo apt install ntpdate

Using the date and wget commands

Another option is to use the date and wget commands to fetch the current date and time from a website and set it on your system. Here’s an example:

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

In this command, date -s sets the system date and time. The wget command fetches the headers from google.com, and grep filters out the line containing the date. The cut command then extracts the date and time, which is passed to date -s.

Updating Time and Date via GUI

If you prefer using a graphical interface, Ubuntu provides an easy way to update the time and date.

  1. Open the Settings application.
  2. Navigate to Details > Date & Time.
  3. Ensure “Automatic Date & Time” is enabled. If it’s already enabled but not updating, try toggling it off and on again.

This method uses NTP to automatically synchronize your system time with the internet.

Advanced Time Synchronization

For more accurate time synchronization, consider using dedicated time servers and configuring tools like ntpq or installing ntpd for continuous adjustment.

sudo apt install ntp

After installing ntpd, you can edit the configuration file /etc/ntp.conf to add your preferred NTP servers.

Remember, accurate system time is not just about having the correct time displayed on your desktop. It’s crucial for system processes, logging, and more. Whether you prefer using the command line or GUI, Ubuntu provides several options to keep your system time accurate and up-to-date.

What is the purpose of updating the time and date on Ubuntu?

Updating the time and date on Ubuntu is crucial for accurate system synchronization, correct timestamping of logs, and ensuring tasks and processes are executed at the correct time.

What is the Network Time Protocol (NTP)?

The Network Time Protocol (NTP) is a protocol used to synchronize the time of computer systems over a network. It allows your Ubuntu system to obtain accurate time information from NTP servers on the internet.

How do I install the `ntpdate` package on Ubuntu?

To install the ntpdate package on Ubuntu, you can use the command sudo apt install ntpdate. This command will fetch and install the package from the Ubuntu repositories.

How can I check if the `ntpdate` command is installed on my Ubuntu system?

You can check if the ntpdate command is installed on your Ubuntu system by running the command ntpdate --version. If it is installed, it will display the version information. If it is not installed, you will see an error message.

How can I enable automatic time synchronization in Ubuntu’s GUI?

To enable automatic time synchronization in Ubuntu’s GUI, open the Settings application, navigate to Details > Date & Time, and toggle the "Automatic Date & Time" option to the enabled position.

Leave a Comment

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