1uname(2)                      System Calls Manual                     uname(2)
2
3
4

NAME

6       uname - get name and information about current kernel
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <sys/utsname.h>
13
14       int uname(struct utsname *buf);
15

DESCRIPTION

17       uname()  returns system information in the structure pointed to by buf.
18       The utsname struct is defined in <sys/utsname.h>:
19
20           struct utsname {
21               char sysname[];    /* Operating system name (e.g., "Linux") */
22               char nodename[];   /* Name within communications network
23                                     to which the node is attached, if any */
24               char release[];    /* Operating system release
25                                     (e.g., "2.6.28") */
26               char version[];    /* Operating system version */
27               char machine[];    /* Hardware type identifier */
28           #ifdef _GNU_SOURCE
29               char domainname[]; /* NIS or YP domain name */
30           #endif
31           };
32
33       The length of the arrays  in  a  struct  utsname  is  unspecified  (see
34       NOTES); the fields are terminated by a null byte ('\0').
35

RETURN VALUE

37       On  success,  zero is returned.  On error, -1 is returned, and errno is
38       set to indicate the error.
39

ERRORS

41       EFAULT buf is not valid.
42

VERSIONS

44       The domainname member (the NIS or YP domain name) is a GNU extension.
45
46       The length of the fields in the struct varies.  Some operating  systems
47       or  libraries  use a hardcoded 9 or 33 or 65 or 257.  Other systems use
48       SYS_NMLN or _SYS_NMLN or UTSLEN or _UTSNAME_LENGTH.  Clearly, it  is  a
49       bad  idea  to  use  any of these constants; just use sizeof(...).  SVr4
50       uses 257, "to support Internet hostnames" — this is the  largest  value
51       likely to be encountered in the wild.
52

STANDARDS

54       POSIX.1-2008.
55

HISTORY

57       POSIX.1-2001, SVr4, 4.4BSD.
58
59   C library/kernel differences
60       Over  time,  increases in the size of the utsname structure have led to
61       three   successive   versions   of   uname():   sys_olduname()    (slot
62       __NR_oldolduname), sys_uname() (slot __NR_olduname), and sys_newuname()
63       (slot __NR_uname).  The first one used length 9  for  all  fields;  the
64       second  used  65; the third also uses 65 but adds the domainname field.
65       The glibc uname() wrapper function hides these  details  from  applica‐
66       tions,  invoking the most recent version of the system call provided by
67       the kernel.
68

NOTES

70       The kernel has the name, release, version, and supported  machine  type
71       built in.  Conversely, the nodename field is configured by the adminis‐
72       trator to match the network (this is what the  BSD  historically  calls
73       the "hostname", and is set via sethostname(2)).  Similarly, the domain‐
74       name field is set via setdomainname(2).
75
76       Part of the utsname information is also accessible  via  /proc/sys/ker‐
77       nel/{ostype, hostname, osrelease, version, domainname}.
78

SEE ALSO

80       uname(1), getdomainname(2), gethostname(2), uts_namespaces(7)
81
82
83
84Linux man-pages 6.05              2023-03-30                          uname(2)
Impressum