Thursday, February 26, 2009

Date and Hardware colck change - ubuntu

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. 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:

sahab@sahab-desktop:~$ sudo date 

Thu Feb 26 15:35:36 PST 2009

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 022706002009

Fri Feb 27 08:00:00 EDT 2009

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:

sahab@sahab-desktop:~$ sudo hwclock --show

Thu 26 Feb 2009 03:43:26 PM PST -0.689380 seconds

Use hwclock with its --set and --date options to manually set the hardware clock like so:

$ sudo hwclock --set --date "02/27/09 08:00:00"

$ sudo hwclock --show
Fri 27 Feb 2009 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; or you can start it from the command line of an X11 terminal window like this:

$ gksudo time-admin &

After you press Enter, you are asked to enter your password. Type in your password and click the OK button. Set the date and time by using the Calendar and Time fields.

No comments: