Linux Command Directory
This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
date [options] [+format] [date]
Print the current date and time. You may specify a display format. format can consist of literal text strings (blanks must be quoted) as well as field descriptors, whose values will appear as described in the following entries (the listing shows some logical groupings). A privileged user can change the system's date and time.
Display current date in a nonstandard format. For example:
$date +"%A %j %n%k %p" Tuesday 248 15 PM
The default is %a %b %e %T %Z %Y (e.g., Tue Sep 5 14:59:37 EDT 2005).
Display date, which should be in quotes and may be in the format d days or m months d days, to print a date in the future. Specify ago to print a date in the past. You may include formatting (see the following section).
Like -d, but printed once for each line of
Display in ISO-8601 format. If specified, timespec can have one of the following values: date (for date only), hours, minutes, or seconds to get the indicated precision.
Display the time file was last modified.
Display the date in RFC 822 format.
Print help message and exit.
Print version information and exit.
Set the date.
Set the date to Greenwich Mean Time, not local time.
The exact result of many of these codes is locale-specific and depends upon your language setting, particularly the LANG environment variable. See locale.
Do not pad fields (default: pad fields with zeros).
Pad fields with space (default: zeros).
Abbreviated month name.
Country-specific date and time format.
Day of month (01-31).
Same as %b.
Julian day of year (001-366).
Hour in 24-hour format, without leading zeros (0-23).
Hour in 12-hour format, without leading zeros (1-12).
Month of year (01-12).
Insert a new line.
String to indicate a.m. or p.m.
Time in %I:%M:%S %p (12-hour) format.
Seconds since "the Epoch," which is 1970-01-01 00:00:00 UTC (a nonstandard extension).
Insert a tab.
Day of week (Sunday = 0).
Country-specific date format based on locale.
Last two digits of year (00-99).
RFC 822-style numeric time zone.
Full month name.
Date in %m/%d/%y format.
Hour in 24-hour format (00-23).
Hour in 12-hour format (01-12).
Time in %H:%M:%S format.
Week number in year (00-53); start week on Sunday.
Week number in year (01-52); start week on Monday.
Week number in year (00-53); start week on Monday.
Country-specific time format based on locale.
Four-digit year (e.g., 2006).
Strings for setting date
Strings for setting the date may be numeric or nonnumeric. Numeric strings consist of time, day, and year in the format MMDDhhmm[[CC] YY] [.ss] . Nonnumeric strings may include month strings, time zones, a.m., and p.m.
A two-digit hour and two-digit minute (hhmm); hh uses 24-hour format.
A two-digit month and two-digit day of month (MMDD); default is current day and month.
The year specified as either the full four-digit century and year or just the two-digit year; the default is the current year.
Set the date to July 1 (0701), 4 a.m. (0400), 2005 (05):
date +"Hello%t Date is %D %n%t Time is %T"
produces a formatted date as follows:
Hello Date is 05/09/05 Time is 17:53:39