
rdate Command in Linux
rdate is a command used in Linux to set the system date and time by querying a remote server. This command is particularly useful for synchronizing your system clock with an external time source, ensuring that your system time is accurate.
Table of Contents
Here is a comprehensive guide to the options available with the rdate command â
- Installing of rdate Command in Linux
- Syntax of rdate Command
- rdate Command Options
- Examples of rdate Command in Linux
Installing of rdate Command in Linux
Linux systems generally do not come with the rdate command preinstalled. You can install it using the package manager that is available on your system.
For Debian-based systems (like Ubuntu) −
sudo apt install rdate
For Red Hat-based systems (like CentOS) −
sudo yum install rdate
For Arch Linux −
sudo pacman -S rdate
Syntax of rdate Command
To execute the rdate command in Linux, use the following basic syntax −
rdate [options] [hostname]
Where −
- [options] are optional parameters that alter the command's functionality.
- [hostname] is the remote server from which the date and time will be retrieved.
rdate Command Options
Here are some various options you can use with the Linux rdate command −
Option | Description |
---|---|
-4 | Uses IPv4 only for the connection. |
-6 | Uses IPv6 only for the connection. |
-a | Applies changes using adjtime for a gradual adjustment. |
-b num | Uses an immediate change if the time difference exceeds num seconds, otherwise uses adjtime. |
-c | Adjusts the count for leap seconds. |
-n | Uses the SNTP protocol instead of the RFC868 protocol. |
-o num | Overrides the default time port with the specified num. |
-p | Prints the retrieved date and time without setting the system clock. |
-s | Sets the system clock without printing the retrieved date and time. |
-u | Uses UDP for the transport protocol instead of TCP. |
-t msec | Does not set the clock if the network delay exceeds msec milliseconds. |
-v | Provides verbose output. |
Examples of rdate Command in Linux
Below are a few examples demonstrating how to use the rdate command in different scenarios on a Linux environment −
- Setting System Time Using IPv4
- Displaying Retrieved Data Over IPv6
- Using Gradual Adjustment with adjtime
- Setting Time with a Threshold
- Synchronizing Time Using SNTP
- Verbose Output
Setting System Time Using IPv4
To set your system's date and time using a remote server over IPv4, run the following command −
rdate -4 -s time.nist.gov
This command queries the time.nist.gov server using IPv4 and updates your system's clock to match the time retrieved from the server.

Displaying Retrieved Date Over IPv6
If you only want to see the date and time from a remote server using IPv6 without changing your system's clock, use this command −
rdate -6 -p time.nist.gov
Executing this command will print the current date and time from time.nist.gov over an IPv6 connection without modifying your system's settings.

Using Gradual Adjustment with adjtime
To gradually adjust your system's time using adjtime, you can use the following command −
rdate -a time.nist.gov
This command retrieves the time from time.nist.gov and applies the changes gradually, smoothing out the adjustment over time.

Setting Time with a Threshold
If you want to use an immediate change only if the time difference exceeds a certain threshold, you can use this command −
rdate -b 60 time.nist.gov
This command will use an immediate change if the time difference with time.nist.gov is greater than 60 seconds; otherwise, it will adjust gradually.

Synchronizing Time Using SNTP
To synchronize your system's clock using the SNTP protocol, run the following command −
rdate -n time.nist.gov
This command queries the time.nist.gov server using SNTP and updates your system's clock accordingly.

Verbose Output
For more detailed information during the synchronization process, you can enable verbose output with this command −
rdate -v time.nist.gov
This command provides additional details about the time synchronization process, making it easier to debug any issues.

Conclusion
The rdate command is a valuable tool for keeping your system's date and time synchronized with an external time source. By understanding the syntax, available options, and practical examples, you can effectively use rdate to ensure your system's clock is accurate.
In this tutorial, we provided the necessary information to utilize rdate efficiently and maintain correct system time.