Friday, December 21, 2007

Changing the DATE or TIME on a LINUX box

taken from

Changing the DATE or TIME on a LINUX box

I discovered the time was off by a number of minutes on one of my servers. The server in question manages website hosting using Ensim WEBppliance Pro 3.5.10 on a Red Hat Linux 7.3 system. To say I am far less familiar with Linux than with windows would be an understatement.

The set of instructions below worked quickly and easily for me from the bash (command) prompt on my Linux machines running:

Red Hat Linux
release 5.2
Kernel 2.0.36
on an i486


Red Hat Linux
release 7.3
Kernel 2.4.20-20.7
on an i586

Under most configurations, you must be logged on as "root" to make this change. You can log on locally (physically at the Linux box) as root. However, if you must perform this remotely (over a network or the Internet), you need to first log on to the machine under a user that will allow you to log on remotely. Then "switch user" to "root" by typing "su" at the prompt and pressing enter. When prompted, type root's password and press enter.

To change the time from the bash prompt, as root, use the "date" command. Typing "date" by itself will return the date, time, and year. Typing "date MMDDhhmmCCYY" will allow you to set any part of the date or time.

Linux Examples:

Login to Linux box as root and enter root's password:

[me@mybox me]$ su

Check the current date and time of the Linux box by entering:

[root@mybox me]# date
Linux yields the current settings:
[root@mybox me]# Wed Apr 7 12:03:45 EDT 2004

Change the current time and date of the Linux box by entering:
[root@mybox me]# date 040713032004
would change the time and yield:
[root@mybox me]$ Wed Apr 7 13:03:00 EDT 2004