How to Set a Date in Linux
The date command allows you to view the current date or change the system date from the command line on any Linux or Unix system. Typing the command with no options will output the current date and time. Using the "-s" option will change the system date. You must be the root user in order to change the system date. You can also use the date command to only change system timestamp.
Instructions
-
-
1
Open a terminal window. The terminal window will be found under the "Utilities" or "Accessories" sub menu of the main "Applications" menu.
-
2
Type the command "su" to become the root user.
-
-
3
Type the command "date -s "01 JAN 2010 00:00:00" to set the date to midnight on January 1, 2010.
-
4
Type the command "date" to check that the change has been made.
-
5
Type the command "exit" to exit the root session.
-
1
Tips & Warnings
You can use a different format to set or view the date, but you must specify the format to be used. For example, the command # date +%Y%m%d -s "20100101" sets the date using a numeric format. The formats accepted can be found in the date man page.