LX0-104 · Question #566
On a dual boot system, every time the system is booted back into Linux the time has been set backward by two hours. Which of the following commands will correct the problem so it will not occur again?
The correct answer is C. hwclock --hctosys --localtime. This problem occurs in dual-boot systems because Windows usually assumes the hardware clock (RTC) stores local time, while Linux typically assumes UTC. The hwclock --hctosys --localtime command tells Linux to treat the hardware clock as local time, resolving the discrepancy.
Question
Options
- Antpdate pool.ntp.org
- Bdate -d 'two hours'
- Chwclock --hctosys --localtime
- Dtime hwclock
How the community answered
(24 responses)- A13% (3)
- B4% (1)
- C79% (19)
- D4% (1)
Why each option
This problem occurs in dual-boot systems because Windows usually assumes the hardware clock (RTC) stores local time, while Linux typically assumes UTC. The `hwclock --hctosys --localtime` command tells Linux to treat the hardware clock as local time, resolving the discrepancy.
`ntpdate` synchronizes the system time with an NTP server but does not permanently change how Linux interprets the hardware clock, so the problem would recur after reboot.
`date -d 'two hours'` temporarily adjusts the system time but does not reconfigure how Linux interacts with the hardware clock, meaning the issue would return on reboot.
The `hwclock` command is used to read and set the hardware clock (RTC). The `--hctosys` option sets the system time from the hardware clock, and `--localtime` specifies that the hardware clock is set to local time rather than UTC, which is common in dual-boot setups with Windows. This configuration ensures that Linux correctly interprets the RTC, preventing time shifts upon reboot.
`time hwclock` measures the execution time of the `hwclock` command itself and does not modify any system time settings or behavior.
Concept tested: Linux hardware clock management in dual-boot systems
Source: https://man7.org/linux/man-pages/man8/hwclock.8.html
Topics
Community Discussion
No community discussion yet for this question.