- slide 1 of 3
When you install a Linux distribution, the installer should query you for your time zone settings. However, be aware that not only does Linux provide a system date and time, your machine provides a date and time also. But, the machine time is based on hardware whereas the system time comes from the Linux operating system itself. Linux system time is based on how many seconds have elapsed since the date of January 1, 1970, but your machine's hardware clock is based on the type of clock chips that were put onto the mother board. Some motherboard chipsets are known to drift. It's no wonder that it's possible for the two times to drift apart. I've seen this happen and you might also; therefore, knowing how to use the Linux set date operation is useful.
- slide 2 of 3
Working With the Date Command Within a Terminal
When someone refers to the "Linux set date" operation, he's actually speaking of the Linux date command. It isn't difficult to use, you'll just want to be accurate since computing is based on keeping track of the time, especially in the case of operations such as running cron jobs. Keeping accurate time is also crucial in a network environment.
In the screen shot below you can see my use of the Linux set date command or simply, the Linux date command. First, I opened a terminal (as root) and typed "date" (commands are without the quote marks) which displayed the system date as you can see. I then typed "hwclock --show" to view what my computer's (hardware) clock was reporting for a date and time. Again, you can see that display as well. I then used the Linux date command to adjust the system's time by typing "date 041311252010." We have "04" for the month of April, "13" for the day, "1125" for the time, and "2010" for the year. I displayed the system time again using the date command. You can also see my second display of the hardware time which reports a different time from the system, same date, but different time.
I passed the "--systohc" option to the "hwclock" command to synchronize the two clocks and then did another display. Now, the system and hardware clocks both report the same date and time. Another option that you can pass to the "hwclock" command is the "hctosys" option to set the system time from your machine's hardware clock instead of the other way around. The "systohc" command can be remembered by saying "system to hardware clock" while the "hctosys" command can be remembered by saying "hardware clock to system." Knowing how to use the Linux set date and hwclock commands with its options in a terminal, also called a console on some systems, is part of Linux administration.