1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>.
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" 2007-07-05 mtk: Added details on underlying system call interfaces
7 .TH uname 2 (date) "Linux man-pages (unreleased)"
9 uname \- get name and information about current kernel
12 .RI ( libc ", " \-lc )
15 .B #include <sys/utsname.h>
17 .BI "int uname(struct utsname *" buf );
21 returns system information in the structure pointed to by
31 char sysname[]; /* Operating system name (e.g., "Linux") */
32 char nodename[]; /* Name within communications network
33 to which the node is attached, if any */
34 char release[]; /* Operating system release
36 char version[]; /* Operating system version */
37 char machine[]; /* Hardware type identifier */
39 char domainname[]; /* NIS or YP domain name */
45 The length of the arrays in a
47 is unspecified (see NOTES);
48 the fields are terminated by a null byte (\[aq]\e0\[aq]).
50 On success, zero is returned.
51 On error, \-1 is returned, and
53 is set to indicate the error.
62 member (the NIS or YP domain name) is a GNU extension.
64 The length of the fields in the struct varies.
65 Some operating systems
66 or libraries use a hardcoded 9 or 33 or 65 or 257.
76 idea to use any of these constants; just use sizeof(...).
77 SVr4 uses 257, "to support Internet hostnames"
78 \[em] this is the largest value likely to be encountered in the wild.
82 POSIX.1-2001, SVr4, 4.4BSD.
83 .SS C library/kernel differences
84 Over time, increases in the size of the
86 structure have led to three successive versions of
90 .IR __NR_oldolduname ),
99 .\" That was back before Linux 1.0
100 used length 9 for all fields;
102 .\" That was also back before Linux 1.0
104 the third also uses 65 but adds the
109 wrapper function hides these details from applications,
110 invoking the most recent version of the system call provided by the kernel.
112 The kernel has the name, release, version, and supported machine type built in.
115 field is configured by the administrator to match the network
116 (this is what the BSD historically calls the "hostname",
118 .BR sethostname (2)).
122 .BR setdomainname (2).
124 Part of the utsname information is also accessible via
125 .IR /proc/sys/kernel/ { ostype ,
132 .BR getdomainname (2),
134 .BR uts_namespaces (7)