You computer's clock does more than just tell you the time. This clock also stamps your email with the correct time as well as documents and much more. So when your PC clock is off, your life is off (at least while you are working). So it is necessary to keep your machine time accurate. But how do you do this? Besides making sure your hardware clock is correct (which is commonly done through the BIOS settings), you need to know how to set the time.
In this article I am going to show you how to change the time on your Ubuntu machine using both the GUI and the command line. Hopefully, when you're done with this, your computer clock will always be accurate.
Of course there is always another option. You can always set up NTP on your machine. I have already covered this in my article "Installing and configuring NTP on Linux". That is, by far, the most reliable way to manage your clock. But when you don't have constant access to the internet, or you simply don't want to install a daemon on your machine - you have to resort to other methods. Let's take a look at them here.
In order to set the date from the command line, you use the date command. The date command, however, is not the simplest command to figure out - at least not from the man page. If you look at the man page for date you see the time format uses a specific time string format like:
What the above string means is:
So, let's say you want to set the correct date and time for this exact moment (the moment I am writing, not your reading). To do this I would enter the command:
sudo date 100507492010.00
at which point you would be returned:
Tue Oct 5 07:50:00 EDT 2010
Now, let's take a look and see how this is done from the graphical front end. To do this click System > Administration > Time and Date. When you do this you will have to click the "lock" button to unlock this tool for changes. When you click this you will have to enter your sudo password. Upon proper authentication you will then be able to use the drop downs for hours, minutes, and seconds. When you change the time, you only need to close the tool, no saving required. NOTE: You can also change the date as well as the timezone with this same tool.
Don't be caught in the future or the past on Linux. Make sure your time is correct so you aren't confusing those receiving your emails (unless you want them to think they are receiving emails from "future you".)Advertisement
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.