What is the command to update time and date from Internet? Is there any application that allows me to do so from its user interface rather than from the shell?
You can do so with e.g.
sudo ntpdate time.nist.gov. Other servers include
http://www.pool.ntp.org/ lists time servers around the world.
As of 2018 with a fresh installed Ubuntu 16.04 LTS, running
sudo ntpdate time.nist.gov gives:
sudo: ntpdate: command not found
This is because (official source):
ntpdateis considered deprecated in favour of
timedatectland thereby no more installed by default.
Instead do this to force the sync to happen now:
sudo timedatectl set-ntp off sudo timedatectl set-ntp on
In my case I was running a Ubuntu on a virtualbox and had saved the machine state so when I started the instance back up again it did not automatically sync the clock since there was no boot event to trigger the sync. So the time was still showing what it was the last time I was running the virtual box.
It's very easy to set up from command line: https://help.ubuntu.com/lts/serverguide/NTP.html From that link:
Ubuntu comes with ntpdate as standard, and will run it once at boot time to set up your time according to Ubuntu's NTP server:
ntpdate -s ntp.ubuntu.com
Here's GUI example https://help.ubuntu.com/community/UbuntuTime#Time_Synchronization_using_NTP
Most here won't work, since ntp will override your settings within seconds.
You need to disable NTP first. On ubuntu it is done as:
# Disable ntp sudo timedatectl set-ntp 0
Then you can do:
# Set software clock sudo date --set="2018-04-01 22:22:22" # Sync with hardware clock sudo hwclock --systohc
Is there any application that allows me to do so from its user interface rather than from the shell?
I'm using 17.10 and can go to Settings (from the upper-right menu in the UI) > Details > Date & Time. In my case, my system wasn't updating from the Internet even though "Automatic Date & Time" was set to "ON". I simply changed it to "OFF", waited a second, then changed it back to "ON". It picked up the current date and time and I was good to go.
You need to install the
ntp package. Date/Time settings are availble under system settings. Here's some more information.
Thanks to Twiglets [For AsusWRT/Merlin Routers]
Here is an alternative that DOES set the date !!! [-s option]. Prints out 'Date' it retrieves & the 'Date' that is set for comparison.
On AsusWRT / Merlin, the only thing that is odd is that the date retrieved is ".... GMT" and the date utility sets the correct time but changes it to "... DST" Environment has TZ set to "GMT"
datetext=$(curl -I 'https://188.8.131.52/' 2>/dev/null | grep "Date:" |sed 's/Date: [A-Z][a-z][a-z], //g'| sed 's/\r//') ; echo "Date Retrieved = $datetext" ; echo -n "Date set = " ; date -s "$datetext" -D'%d %b %Y %T %Z'