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 2021-03-22 "Linux" "Linux Programmer's Manual"
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.
60 POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD.
64 member (the NIS or YP domain name) is a GNU extension.
66 The kernel has the name, release, version, and supported machine type built in.
69 field is configured by the administrator to match the network
70 (this is what the BSD historically calls the "hostname",
76 .BR setdomainname (2).
78 The length of the fields in the struct varies.
79 Some operating systems
80 or libraries use a hardcoded 9 or 33 or 65 or 257.
90 idea to use any of these constants; just use sizeof(...).
91 SVr4 uses 257, "to support Internet hostnames"
92 \(em this is the largest value likely to be encountered in the wild.
94 Part of the utsname information is also accessible via
95 .IR /proc/sys/kernel/ { ostype ,
100 .SS C library/kernel differences
101 Over time, increases in the size of the
103 structure have led to three successive versions of
107 .IR __NR_oldolduname ),
116 .\" That was back before Linux 1.0
117 used length 9 for all fields;
119 .\" That was also back before Linux 1.0
121 the third also uses 65 but adds the
126 wrapper function hides these details from applications,
127 invoking the most recent version of the system call provided by the kernel.
130 .BR getdomainname (2),
132 .BR uts_namespaces (7)