Linux systems can sync with time servers on the Internet using the Network Time Protocol (NTP). The ntpdate command sets the clock initially, while the ntp daemon periodically monitors the clock skew and adjusts the system time accordingly.
Installing the required packages
If you don't know what system you're on, please see How To Check Your Linux Version
On RedHat Enterprise Linux (RHEL):
sudo up2date install ntp
On CentOS:
sudo yum install ntp
On Ubuntu:
sudo apt-get install ntp ntpdate
Syncing the clock initially
The command to initially sync the clock is:
sudo ntpdate -u pool.ntp.org
You may want to run the command a few times until the reported offset is less than 1.0. Your clock should now be accurate.
Keeping the clock accurate
The ntp daemon periodically monitors the clock skew and adjusts the system time accordingly. It should be started now, then configured to automatically start when the system boots.
On RedHat or CentOS:
sudo service ntpd start
sudo chkconfig ntpd on
On Ubuntu systems, the ntp daemon is started automatically and is automatically configured to start on boot when the ntp package is installed.
