[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This section describes commands that print or change system-wide information.
21.1 date
: Print or set system date and timePrint or set system date and time. 21.2 uname
: Print system informationPrint system information. 21.3 hostname
: Print or set system namePrint or set system name. 21.4 hostid
: Print numeric host identifier.Print numeric host identifier.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
date
: Print or set system date and time Synopses:
date [option]... [+format] date [-u|--utc|--universal] [ MMDDhhmm[[CC]YY][.ss] ] |
Invoking date
with no format argument is equivalent to invoking
`date '+%a %b %e %H:%M:%S %Z %Y''.
If given an argument that starts with a `+', date
prints the
current time and date (or the time and date specified by the
--date
option, see below) in the format defined by that argument,
which is the same as in the strftime
function. Except for
directives, which start with `%', characters in the format string
are printed unchanged. The directives are described below.
21.1.1 Time directives %[HIklMprsSTXzZ] 21.1.2 Date directives %[aAbBcdDhjmUwWxyY] 21.1.3 Literal directives %[%nt] 21.1.4 Padding Pad with zeroes, spaces (%_), or nothing (%-). 21.1.5 Setting the time Changing the system clock. 21.1.6 Options for date
Instead of the current time. 21.1.7 Examples of date
Examples.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
date
directives related to times.
%H:%M
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
date
directives related to dates.
%Y-%m-%d
.
This is the preferred form for all uses.
00
through 99
). This has the same format and value
as %y
, except that if the ISO week number (see %V
) belongs
to the previous or next year, that year is used instead.
%Y
, except that if the ISO week number (see
%V
) belongs to the previous or next year, that year is used
instead.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
date
directives that produce literal strings.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
By default, date
pads numeric fields with zeroes, so that, for
example, numeric months are always output as two digits. GNU date
recognizes the following numeric modifiers between the `%' and the
directive.
These are GNU extensions.
Here is an example illustrating the differences:
date +%d/%m -d "Feb 1" => 01/02 date +%-d/%-m -d "Feb 1" => 1/2 date +%_d/%_m -d "Feb 1" => 1/ 2 |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If given an argument that does not start with `+', date
sets
the system clock to the time and date specified by that argument (as
described below). You must have appropriate privileges to set the
system clock. The `--date' and `--set' options may not be
used with such an argument. The `--universal' option may be used
with such an argument to indicate that the specified time and date are
relative to Coordinated Universal Time rather than to the local time
zone.
The argument must consist entirely of digits, which have the following meaning:
The `--set' option also sets the system clock; see the next section.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
date
The program accepts the following options. Also see 2. Common options.
date
executable many times can
be considerable.
The argument timespec specifies the number of additional terms of the time to include. It can be one of the following:
If showing any time terms, then include the time zone using the format `%z'.
If timespec is omitted with `--iso-8601', the default is
`auto'. On older systems, GNU date
instead
supports an obsolete option `-I[timespec]', where
timespec defaults to `auto'. POSIX 1003.1-2001
(see section 2.5 Standards conformance) does not allow `-I' without an
argument; use `--iso-8601' instead.
TZ
environment variable were set to the string `UTC0'.
Normally, date
operates in the time zone indicated by
TZ
, or the system default if TZ
is not set. Coordinated
Universal Time is often called "Greenwich Mean Time" (GMT) for
historical reasons.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
date
Here are a few examples. Also see the documentation for the `-d' option in the previous section.
date --date='2 days ago' |
date --date='3 months 1 day' |
date --date='25 Dec' +%j |
date '+%B %d' |
But this may not be what you want because for the first nine days of the month, the `%d' expands to a zero-padded two-digit field, for example `date -d 1may '+%B %d'' will print `May 01'.
-
modifier to suppress
the padding altogether.
date -d 1may '+%B %-d |
date
when setting the system clock:
date +%m%d%H%M%Y.%S |
date --set='+2 minutes' |
Mon, 25 Mar 1996 23:34:17 -0600 |
date --date='1970-01-01 00:02:00 +0000' +%s 120 |
If you do not specify time zone information in the date string,
date
uses your computer's idea of the time zone when
interpreting the string. For example, if your computer's time zone is
that of Cambridge, Massachusetts, which was then 5 hours (i.e., 18,000
seconds) behind UTC:
# local time zone used date --date='1970-01-01 00:02:00' +%s 18120 |
date --date='2000-01-01 UTC' +%s 946684800 |
To convert such an unwieldy number of seconds back to a more readable form, use a command like this:
# local time zone used date -d '1970-01-01 UTC 946684800 seconds' +"%Y-%m-%d %T %z" 1999-12-31 19:00:00 -0500 |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
uname
: Print system information
uname
prints information about the machine and operating system
it is run on. If no options are given, uname
acts as if the
-s
option were given. Synopsis:
uname [option]... |
If multiple options or -a
are given, the selected information is
printed in this order:
kernel-name nodename kernel-release kernel-version machine processor hardware-platform operating-system |
The information may contain internal spaces, so such output cannot be parsed reliably. In the following example, release is `2.2.18ss.e820-bda652a #4 SMP Tue Jun 5 11:24:08 PDT 2001':
uname -a => Linux dum 2.2.18ss.e820-bda652a #4 SMP Tue Jun 5 11:24:08 PDT 2001 i686 unknown unknown GNU/Linux |
The program accepts the following options. Also see 2. Common options.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
hostname
: Print or set system name
With no arguments, hostname
prints the name of the current host
system. With one argument, it sets the current host name to the
specified string. You must have appropriate privileges to set the host
name. Synopsis:
hostname [name] |
The only options are `--help' and `--version'. See section 2. Common options.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
hostid
: Print numeric host identifier.
hostid
prints the numeric identifier of the current host
in hexadecimal. This command accepts no arguments.
The only options are `--help' and `--version'.
See section 2. Common options.
For example, here's what it prints on one system I use:
$ hostid 1bac013d |
On that system, the 32-bit quantity happens to be closely related to the system's Internet address, but that isn't always the case.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |