1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.\" 2007-07-05 mtk: Added details on underlying system call interfaces
.\"
.TH uname 2 2024-06-15 "Linux man-pages (unreleased)"
.SH NAME
uname \- get name and information about current kernel
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.B #include <sys/utsname.h>
.P
.BI "int uname(struct utsname *" buf );
.fi
.SH DESCRIPTION
.BR uname ()
returns system information in the structure pointed to by
.IR buf .
The
.I utsname
struct is defined in
.IR <sys/utsname.h> :
.P
.in +4n
.EX
struct utsname {
char sysname[]; /* Operating system name (e.g., "Linux") */
char nodename[]; /* Name within communications network
to which the node is attached, if any */
char release[]; /* Operating system release
(e.g., "2.6.28") */
char version[]; /* Operating system version */
char machine[]; /* Hardware type identifier */
#ifdef _GNU_SOURCE
char domainname[]; /* NIS or YP domain name */
#endif
};
.EE
.in
.P
The length of the arrays in a
.I struct utsname
is unspecified (see NOTES);
the fields are terminated by a null byte (\[aq]\[rs]0\[aq]).
.SH RETURN VALUE
On success, zero is returned.
On error, \-1 is returned, and
.I errno
is set to indicate the error.
.SH ERRORS
.TP
.B EFAULT
.I buf
is not valid.
.SH VERSIONS
The
.I domainname
member (the NIS or YP domain name) is a GNU extension.
.P
The length of the fields in the struct varies.
Some operating systems
or libraries use a hardcoded 9 or 33 or 65 or 257.
Other systems use
.B SYS_NMLN
or
.B _SYS_NMLN
or
.B UTSLEN
or
.BR _UTSNAME_LENGTH .
Clearly, it is a bad
idea to use any of these constants; just use sizeof(...).
SVr4 uses 257, "to support Internet hostnames"
\[em] this is the largest value likely to be encountered in the wild.
.SH STANDARDS
POSIX.1-2008.
.SH HISTORY
POSIX.1-2001, SVr4, 4.4BSD.
.SS C library/kernel differences
Over time, increases in the size of the
.I utsname
structure have led to three successive versions of
.BR uname ():
.IR sys_olduname ()
(slot
.IR __NR_oldolduname ),
.IR sys_uname ()
(slot
.IR __NR_olduname ),
and
.IR sys_newuname ()
(slot
.IR __NR_uname) .
The first one
.\" That was back before Linux 1.0
used length 9 for all fields;
the second
.\" That was also back before Linux 1.0
used 65;
the third also uses 65 but adds the
.I domainname
field.
The glibc
.BR uname ()
wrapper function hides these details from applications,
invoking the most recent version of the system call provided by the kernel.
.SH NOTES
The kernel has the name, release, version, and supported machine type built in.
Conversely, the
.I nodename
field is configured by the administrator to match the network
(this is what the BSD historically calls the "hostname",
and is set via
.BR sethostname (2)).
Similarly, the
.I domainname
field is set via
.BR setdomainname (2).
.P
Part of the utsname information is also accessible via
.IR /proc/sys/kernel/ { ostype ,
.IR hostname ,
.IR osrelease ,
.IR version ,
.IR domainname }.
.SH SEE ALSO
.BR uname (1),
.BR getdomainname (2),
.BR gethostname (2),
.BR uts_namespaces (7)
|