Linux Commands

Hwclock Command

The “hwclock” is a command-line utility for both Linux and Unix-like operating systems to access Hardware Clock. It is also termed as Real-Time Clock (RTS) or BIOS clock.

The Hardware Clock is quite different from the clock that is managed by the Linux kernel. It runs when the system is running, and it even remains active when the machine is turned off as it is independent of the operating system you are using.

The Configuration of Hardware Clock can be modified from BIOS. User can also set and view the hardware time using the “hwclock” command:

Syntax:

Syntax of “hwclock” command is:

hwclock [function] [options]…

Getting Started with hwclock:

The “hwclock” tool performs different functionalities with various options.

To display the hardware clock’s date and time on the terminal, type “hwclock” in the command-line. The result will be the same as the time and date are set in your BIOS:

D:\Warda\march\17\Hwclock Command Tutorial\Hwclock Command Tutorial\images\image4 final.png

hwclock Functions:

To display Real-Time Clock (RTC) on the terminal, use “-r” or “–show.” You will get the same results.

$ sudo hwclock –r

Or

$ sudo hwclock --show

D:\Warda\march\17\Hwclock Command Tutorial\Hwclock Command Tutorial\images\image6 final.png

Adjust Hardware Clock:

To control the adjustment of RTC when your system starts, use the “adjust” command:

$ sudo hwclock -adjust

D:\Warda\march\17\Hwclock Command Tutorial\Hwclock Command Tutorial\images\image5 final.png

There are many other functions of “hwclock” as well:

  • There might be a case when your system clock is not accurate, but the Hardware Clock is. In this case, “-s” or “-hctosys” is used to copy hardware clock time to the system clock time.
  • -w” or “-systohoc” is contrary to “hctosys.” It copies system time and sets RTC. Or we can say if your hardware clock time is not accurate, then this command will set the BIOS time according to the system’s time.
  • The “systz” function is used to send the configuration of the timescale to the kernel.

hwclock Options:

There are few options of the “hwclock” command:

The “-u” or “–utc” option is used when you want to display that timescale of RTC is UTC.

$ sudo hwclock –u

Or

$ sudo hwclock --utc

-l” or “–localtime” option is used when you want to display that timescale of RTC is Local- time:

$ sudo hwclock –l

Or

$ sudo hwclock --localtime

To print the debug information, use the “debug” option in the terminal with “hwclock”:

$ sudo hwclock -D

Or

$ sudo hwclock --debug

D:\Warda\march\17\Hwclock Command Tutorial\Hwclock Command Tutorial\images\image2 final.png

-v” option is used to display version information of “hwclock” in the terminal:

$ sudo hwclock -v

D:\Warda\march\17\Hwclock Command Tutorial\Hwclock Command Tutorial\images\image1 final.png

Use the “help” option to get detailed information about the “hwclock” tool in the terminal:

$ sudo hwclock --help

D:\Warda\march\17\Hwclock Command Tutorial\Hwclock Command Tutorial\images\image3 final.png

Conclusion:

The “hwclock” is a utility that is used to access hardware time. It is also known as RTC (Real Time Clock) and different from Linux Kernel’s clock. In this Linux command tutorial, we learned how Hardware Clockworks. We have also mentioned the usage of the “hwclock” command and its various options.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.