Linux set date and time from command prompt
Q. How can I set the system date and time from the command prompt (bash shell)? I don't have GUI installed and I am login over ssh session.
A. Use date command to display the current date and time or set the system date and time over ssh session.
This is useful if the Linux server time and/or date is wrong, and you need to set it to new values from the shell prompt.
Task: Set new date / time
Use the following syntax to set new data and time:
date set="STRING"
For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
# date -s "2 OCT 2006 18:00:00"
You can also set new timzone using this mini-howto.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Linux or FreeBSD command to display system time and date
- FreeBSD: Set date time and timezone
- PHP script to find and print the current date and time
- OpenBSD Set Date and Time
- How to format date for display or to use in a shell script
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: BASH Shell, current date, date command, date time, debian linux, fedora linux, gentoo linux, linux date set, linux date setting, linux date timezone, linux datetime, linux set date, linux set time, new date, server time, syntax, unix date ~ Last updated on: March 12, 2008



April 8th, 2007 at 8:51 pm
Found out i had to set the date like this:
# date -s 2007.04.08-22:46+0000
December 12th, 2007 at 6:57 am
How can I set the proxy setting from the command prompt (bash shell)?
January 10th, 2008 at 7:25 am
Just This code is ultimate.It is simple and worth full.Thank you very much providing help to people.
March 8th, 2008 at 4:26 am
It Work’s Thanks a Lot,
Kiran.