1UNAME(2)                   Linux Programmer's Manual                  UNAME(2)
2
3
4

NAME

6       uname - get name and information about current kernel
7

SYNOPSIS

9       #include <sys/utsname.h>
10
11       int uname(struct utsname *buf);
12

DESCRIPTION

14       uname()  returns system information in the structure pointed to by buf.
15       The utsname struct is defined in <sys/utsname.h>:
16              struct utsname {
17                      char sysname[];
18                      char nodename[];
19                      char release[];
20                      char version[];
21                      char machine[];
22              #ifdef _GNU_SOURCE
23                      char domainname[];
24              #endif
25              };
26       The length of the arrays in a struct utsname is unspecified; the fields
27       are terminated by a null byte ('' ').
28

RETURN VALUE

30       On  success,  zero is returned.  On error, -1 is returned, and errno is
31       set appropriately.
32

ERRORS

34       EFAULT buf is not valid.
35

CONFORMING TO

37       SVr4, POSIX.1-2001.  There is no uname() call in 4.3BSD.
38
39       The domainname member (the NIS or YP domain name) is a GNU extension.
40

NOTES

42       This is a system call, and the operating system  presumably  knows  its
43       name, release and version. It also knows what hardware it runs on.  So,
44       four of the fields of the struct are meaningful.  On  the  other  hand,
45       the  field  nodename  is  meaningless: it gives the name of the present
46       machine in some undefined network, but typically machines are  in  more
47       than  one  network  and have several names. Moreover, the kernel has no
48       way of knowing about such things, so it has to be told what  to  answer
49       here.  The same holds for the additional domainname field.
50
51       To  this  end Linux uses the system calls sethostname(2) and setdomain‐
52       name(2).  Note that there is no standard that says  that  the  hostname
53       set  by  sethostname(2) is the same string as the nodename field of the
54       struct returned by uname() (indeed, some systems allow a 256-byte host‐
55       name and an 8-byte nodename), but this is true on Linux. The same holds
56       for setdomainname(2) and the domainname field.
57
58       The length of the fields in the struct varies. Some  operating  systems
59       or  libraries  use  a hardcoded 9 or 33 or 65 or 257. Other systems use
60       SYS_NMLN or _SYS_NMLN or UTSLEN or _UTSNAME_LENGTH. Clearly,  it  is  a
61       bad  idea  to  use any of these constants; just use sizeof(...).  Often
62       257 is chosen in order to have room for an internet hostname.
63
64       There have been three Linux system calls uname(). The  first  one  used
65       length  9,  the second one used 65, the third one also uses 65 but adds
66       the domainname field.
67
68       Part of the utsname information is also accessible via sysctl() and via
69       /proc/sys/kernel/{ostype, hostname, osrelease, version, domainname}.
70

SEE ALSO

72       uname(1), getdomainname(2), gethostname(2)
73
74
75
76Linux 2.5.0                       2001-12-15                          UNAME(2)
Impressum