LinuxCommandLibrary

rdate

Set system date and time from server

SYNOPSIS

rdate [-46aclnpsuv] [-o port] [-t timeout] hostname...

PARAMETERS

-4
    Force rdate to use IPv4 addresses only.

-6
    Force rdate to use IPv6 addresses only.

-a
    Adjust the time gradually. This attempts to avoid abrupt changes in the system clock, potentially affecting running applications.

-c
    Do not trust the source port of the time packets and check that the remote host is the one we expect.

-l
    Local mode. This option prints the current local time in RFC868/timestamp format. No network communication is performed.

-n
    Dry run. Display time but do not set it.

-o port
    Specify the port to use. By default, the rdate command uses port 37 for the Time Protocol and 123 for NTP.

-p
    Use the TCP protocol instead of UDP.

-s
    Set the time silently. Do not print any messages to standard output.

-t timeout
    Specify a timeout in seconds. This defines how long rdate will wait for a response from the server.

-u
    Use UDP.

-v
    Verbose output. Print more detailed information about the process.

hostname...
    One or more hostnames or IP addresses of time servers. rdate will attempt to connect to each server in the order they are listed.
Note that the first hostname in the list that responds is used, without checking the time accuracy.

DESCRIPTION

rdate is a command-line utility that retrieves the date and time from a remote server using the Time Protocol (RFC 868) or the Network Time Protocol (NTP). It then sets the system's date and time to match the server's time. This is useful for synchronizing a system's clock with a reliable time source, especially when a hardware clock is not accurate or available.
rdate is not secure as it uses the unencrypted Time Protocol or a simplified version of NTP without authentication. Modern systems usually prefer NTP clients (like chrony or systemd-timesyncd) that provide more accurate and secure time synchronization. It should be used with caution, especially over untrusted networks, and may not be available on all systems as it is considered legacy.

CAVEATS

rdate is considered insecure because it does not provide authentication or encryption, making it vulnerable to man-in-the-middle attacks. It is also less accurate than modern NTP implementations. Use NTP daemons like chronyd or systemd-timesyncd instead.

EXIT STATUS

The rdate utility exits 0 on success, and >0 if an error occurs.

SECURITY CONSIDERATIONS

Using rdate over untrusted networks poses a significant security risk due to its lack of authentication. A malicious actor can easily spoof the time server and set the system clock to an incorrect value, potentially disrupting operations or exploiting time-based vulnerabilities.

HISTORY

rdate has been a part of Unix-like systems for a long time, primarily used when more sophisticated time synchronization methods were not available or practical. Its usage has declined with the advent of NTP and its secure alternatives, but it can still be found on some embedded systems or older Linux distributions where resource constraints are a concern.

SEE ALSO

ntpd(8), date(1), chronyc(1), systemd-timesyncd(8)

Copied to clipboard