oreilly.comSafari Books Online.Conferences.


Linux in a Nutshell

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.

Buy it now, or read it online 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).

-d date, --date date

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).

-f datefile, --file=datefile

Like -d, but printed once for each line of datefile.

-I [timespec] , --iso-8601[=timespec]

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.

-r file, --reference=file

Display the time file was last modified.

-R, --rfc-822

Display the date in RFC 822 format.


Print help message and exit.


Print version information and exit.

-s date, --set date

Set the date.

-u, --universal

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.


Literal %.

- (hyphen)

Do not pad fields (default: pad fields with zeros).

_ (underscore)

Pad fields with space (default: zeros).


Abbreviated weekday.


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 weekday.


Full month name.


Date in %m/%d/%y format.


Hour in 24-hour format (00-23).


Hour in 12-hour format (01-12).


Minutes (00-59).


Seconds (00-59).


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).


Time-zone name.

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 0701040095

The command:

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

Linux Resources
  • Linux Online
  • The Linux FAQ
  • Linux Kernel Archives
  • Kernel Traffic

  • Sponsored by: