- Troubleshooting Post-Installation Configuration Problems
- The sudo command
- First Update
- Configuring Software Repositories
- Installing Graphics Drivers
- Changing Ubuntu's Look and Feel
- Preferred Behaviors
- Input Devices
- Detecting and Configuring a Modem
- Configuring Power Management in Ubuntu
- Resetting the Date and Time
- Configuring and Using CD, DVD, and CD-RW Drives
- Configuring Wireless Networks
- Configuring Firestarter
Resetting the Date and Time
The Ubuntu installer queries during installation for default time zone settings, and whether your computer's hardware clock is set to Greenwich mean time (GMT)—more properly known as UTC or coordinated universal time.
Linux provides a system date and time; your computer hardware provides a hardware clock-based time. In many cases, it is possible for the two times to drift apart. Linux system time is based on the number of seconds elapsed since January 1, 1970. Your computer's hardware time depends on the type of clock chips installed on your PC's motherboard, and many motherboard chipsets are notoriously subject to drift.
Keeping accurate time is not only important on a single workstation, but also critically important in a network environment. Backups, scheduled downtimes, and other networkwide actions need to be accurately coordinated.
Ubuntu provides several date and time utilities you can use at the command line or during an X session, including these:
- date—Used to display, set, or adjust the system date and time from the command line
- hwclock—A root command to display, set, adjust, and synchronize hardware and system clocks
- time-admin—Ubuntu's graphical date, time, and network time configuration tool
Using the date Command
Use the date command to display or set your Linux system time. This command requires you to use a specific sequence of numbers to represent the desired date and time. To see your Linux system's idea of the current date and time, use the date command like this:
$ sudo date Wed Jan 10 14:17:01 EDT 2005
To adjust your system's time (say, to January 27, 2006 at 8 a.m.), use a command line with the month, day, hour, minute, and year, like so:
$ sudo date 012606002003 Fri Jan 27 08:00:00 EDT 2006
Using the hwclock Command
Use the hwclock command to display or set your Linux system time, display or set your PC's hardware clock, or to synchronize the system and hardware times. To see your hardware date and time, use hwclock with its --show option like so:
$ sudo hwclock --show Fri 27 Jan 2006 02:17:53 PM GMT -0.193809 seconds
Use hwclock with its --set and --date options to manually set the hardware clock like so:
$ sudo hwclock --set --date "01/27/06 08:00:00" $ sudo hwclock --show Tue 27 Jan 2006 08:00:08 AM GMT -0.151718 seconds
In these examples, the hardware clock has been set using hwclock, which is then used again to verify the new hardware date and time. You can also hwclock to set the Linux system date and time date using your hardware clock's values with the Linux system date and time.
For example, to set the system time from your PC's hardware clock, use the --hctosys option like so:
$ sudo hwclock --hctosys
To set your hardware clock using the system time, use the --systohc option like so:
$ sudo hwclock --systohc
Changing the Time and Date
Ubuntu's graphical X tool named time-admin can be used to set your system date and time. The client is found in System, Administration, Time & Date.
After you press Enter, you are asked to enter your password. Type in your password and click the OK button. You will then see a window, as shown in Figure 2.16.
Figure 2.16 Use Ubuntu's time-admin client to set your system date and time.
Set the date and time by using the Calendar and Time fields. You can also have your workstation obtain updated date and time information via the Internet by choosing Remote Time Servers under the Select Servers button. To do this, you need to have ntpd time daemon support installed. If it is not present, Ubuntu asks whether you want to retrieve it, and then installs it so that you can proceed. After it has been installed, restart the time-admin client and you will now be able to select specific Internet time servers for you to synchronize with.