/ factorpad.com / tech / linux-essentials / date-command.html
An ad-free and cookie-free website.
Beginner
Learn to find and set system date and time at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux date Command Summary with Examples (3:40)
Our fifteenth word, or command to memorize is date
from the category System.
date
allows you to display or set the
system time and date.
-options | description |
---|---|
--help |
Print help screen |
--date |
Display a different date or time other than now |
--set |
Set the system date |
Recall from our last video (tutorial) we talked about answering
questions, and the date
will help us
answer the when question.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
The date
command has
10 options and the most common argument is a
date/time format which can be highly customized.
I suggest reviewing the manual page and the double-dash
--h
option because Linux is very
particular about the format for printing out and adjusting dates and
times.
The default without options is the current time. The option
--date
shows a time other than now,
and --set
is for setting time.
And now you know how to do that.
So why is date
an important command?
Well, most of us already know what time it is, but date helps us print
system time on reports. Also, accurately calendering jobs is dependent
on you ensuring that the system time is correct.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go, type date
to see date
and time, in standard format.
And to see the extensive list of formats, type double-dash
date --h
.
Then Shift-PgUp
to scroll,
Shift-PgDn
. Take a look at that.
It's quite a list. Wow!
Next, let's use double-dash
--date="yesterday"
to show
yesterday's date.
And then last, let's see the date yesterday, using a plus and this
format +%D
.
Okay now you know how to use date
.
And you know the syntax for commands, options and arguments.
One last tip about the date
command.
I suggest reviewing the user manual for
date
and be careful when setting the
system time. Next we'll cover another time-related command.
Okay, thanks for visiting today. I hope this was a fun introduction
to the date
command.
Don't miss our next video tutorial. Subscribe at YouTube, follow @factorpad on Twitter and join our no-spam email list.
whereis
command,
hit Back.touch
command, click Next./ factorpad.com / tech / linux-essentials / date-command.html
A newly-updated free resource. Connect and refer a friend today.