I have ntpd running on a box. I want to see how the time on the box compares to the time retrieved from ntp.ubuntu.com. Is there an easy way to do this?
You can use ntpdate to query a time server
ntpdate -q ntp.ubuntu.com
There are a few different options for querying an ntp server now that ntpdate is deprecated. Which is preferred is often simply a matter of which is already installed (or easy to install) on your OS:
sntp is a tool from the ntp project, and is their recommended tool for querying remote servers:
$ sntp -K/dev/null ntp.ubuntu.com 2021-10-12 16:01:48.425034 (+0700) -0.175372 +/- 0.128998 secs
-K/dev/null is optional, and disables persisting information about the requests to a file. Normal users typically won't have access to this file, so without that option it will print some errors but will otherwise work.
chronyd is an alternative ntp implementation and the default time server in recent RHEL and Ubuntu distributions.
$ chronyd -Q "server ntp.ubunutu.com iburst" 2021-10-27T21:55:49Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG) 2021-10-27T21:55:49Z Disabled control of system clock 2021-10-27T21:55:53Z System clock wrong by -0.233053 seconds (ignored) 2021-10-27T21:55:53Z chronyd exiting
-Q tells it to query the server and print results without setting the time (capital is important - lowercase will set the time!). By default it will query the servers configured in it's config file, but you can also give a config line as done above.
server is used to specify a single NTP server to query, but
refclock could also be used.
iburst configures it get an initial result more quickly.