Knowledge Base

Browse our knowledge base for free solutions to common problems

Change System & Hardware Clock & Date on Linux Without NTP Install

Created On: 14 September 2022
Written by: Ben

This article describes the steps to change the system and hardware clock on linux without the need to use ntp. The steps described in this article are performed on CentOS 6.

Current System Times & Dates

The best way to get started is to find out the times which the system is currently using. One Linux and most operating systems we have two time settings:

  1. Hardware time
  2. System time

To check the hardware time the following command can be issued:

hwclock

My hardware clock is set to 04:37 AM AST.

To check the system clock we can issue the following command:

date

My system clock is set to 04:40 AM AST, the same as the hardware clock.

Changing System Times & Dates

To change the system clock we simply remove the /etc/localtime file and then recreate the file using a symbolic link to a timezone file which comes pre-packed on the system.

First remove the localtime file with the following:

rm -rf /etc/localtime

Now recreate the file as a symbolic link from the timezone file of your choice, in my case I choose "Europe/London":

ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

You can find more about the different timezones here.

The next thing to do is to change the zone information inside of the clock config file to represent the timezone you used above:

nano /etc/sysconfig/clock    
or     
vi /etc/sysconfig/clock

Finally you can run the following command to make the hardware clock sync with the system clock:

hwclock --systohc --localtime

Check The Changes

You can now check the changes by issuing the following commands again:

hwclock
date

They should now both match. This will also change the Timezone the machine is running as well as the date when required!

ICTU LTD is a company registered England and Wales (Company No. 09344913) 15 Queen Square, Leeds, West Yorkshire, England, LS2 8AJ
Copyright © 2024 ICTU LTD, All Rights Reserved.
exit