How do I set the date and time in linux from the command line?

Linux Set Date and Time From a Command Prompt


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. How can I set date under Linux operating systems?

Use the date command to display the current date and time or set the system date / time over ssh session. You can also run the date command from X terminal as root user.



Tutorial details 
Difficulty Easy (rss)
Root privileges Yes
Requirements None
Estimated completion time 2m
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.


You must login as root user to use date command.

Linux Display Current Data and Time

Just type the date command:
$ date
Sample outputs:

Wed Apr 23 10:32:59 CDT 2014

Linux Display The Hardware Clock (RTC)

Type the following hwclock command to read the Hardware Clock and display the time on screen:
# hwclock -r
# hwclock --show
OR show it in Coordinated Universal time (UTC):
# hwclock --show --utc
Sample outputs:

Wed 23 Apr 2014 10:36:23 AM CDT  -0.157239 seconds

Linux Set Date Command Example

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"
# date --set="2 OCT 2006 18:00:00"
You can also simplify format using following syntax:
# date +%Y%m%d -s "20081128"

Linux Set Time Examples

To set time use the following syntax:
# date +%T -s "10:13:13"

  • 10: Hour (hh)
  • 13: Minute (mm)
  • 13: Second (ss)

Use %p locale's equivalent of either AM or PM, enter:
# date +%T%p -s "6:10:30AM"
# date +%T%p -s "12:10:30PM"

How do I set the Hardware Clock to the current System Time?

Use the following syntax:
# hwclock --systohc
# hwclock -w

Thanks to for a awesome guide!

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How do I change my remember password options in Google Chrome

Manage your website passwords This article applies to the Google Chrome browser on Windows,...

Change time is Gmail

Correct Your Gmail Time Zone To set your Gmail time zone: Click the gear in your Gmail's...

How to speed up Windows XP use at your own risk

Warning: occasionally people break their PC badly by using this list of suggestions. Usually...

How to run cmd in escalated mode with admin rights to modify firewall

a solution: runas /user:administrator@domainname.local cmd then in the resulting command...

How do I enable auto login in Windows

This article describes how to configure Windows to automate the logon...