Get or set current system time on Ubuntu Linux using the terminal

Managing the date and time on a Linux system is fairly simple using the command line. Once you are familiar with the relevant command and its syntax, it is very easy to get and set the system date/time properly.

The commands shown below are tested on Ubuntu Linux but should work well on most if not all other popular variants of Linux.

The following tutorial explains.

Getting the current system date/time on Ubuntu using the terminal

To get the current Ubuntu system date/time, execute the following command in a terminal:


You will get the server's current date and time in the following format:

Sun Sep 18 11:04:08 EST 2011

As you can see, you get the day of the week, the date, the time, the current timezone, and the year.

Setting the current system date/time on Ubuntu using the terminal

The command and format for setting the new system time is a bit strange and is shown below. Note that this command must be run as root:

  • nn - is the 2 digit month (01 to 12)
  • dd - is the 2 digit day (01 to 28/30/31)
  • hh - is the 2 digit hour (00 to 23)
  • mm - is the 2 digit minute (00 to 59)
  • yyyy - is the 2/4 digit year (using 4 digits for the year is advised)
  • ss - is the 2 digit seconds (00 to 59)

In other words, if we want to set the date and time to September 13, 2007 9:59:32PM, we would execute the following command in a terminal as root:

date 091321592007.32

And that's it. Your time is now set to what you just entered. You can check by running the date command again.

You may also want to change the timezone on your Ubuntu system using the command line as well.

We hope this Ubuntu tutorial was helpful.

Thank Tutorial Arena for This Tutorial.
Show your appreciation with a +1...