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.
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
[root@mybox me]# Tue Aug 4 12:03:45 CEST 2009
Change the current time and date of the Linux box by entering:
- 2-digits month => 08
- 2-digits day => 04
- 2-digits hour => 12
- 2-digits minutes =>03
- 4-digits year =>2009
[root@mybox me]# date 080412032009
[root@mybox me]$ Tue Aug 4 12:03:00 CEST 2009