uname(2)

๐Ÿ’– uname(2) โ€” the manual page, but make it cute โœจ

okay bestie, welcome to uname(2), a classic from the System Calls Manual. she gets you the name and info about the kernel you're currently running on, no cap ๐Ÿ’…


๐ŸŒธ NAME ๐ŸŒธ

uname โ€” get name and information about current kernel

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc) ๐Ÿซถ

โœจ SYNOPSIS โœจ

#include <sys/utsname.h>

int uname(struct utsname *buf);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so uname() hands you back all the system info, and it puts it in the structure that buf is pointing at. and the utsname struct lives in <sys/utsname.h>, and she looks like this:

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
};

okay important thing, bestie: the length of those arrays in a struct utsname is unspecified (peep VERSIONS and HISTORY if you wanna know more), and every field is terminated by a null byte ('\0'). periodt. ๐ŸŽ€

๐Ÿ’ซ RETURN VALUE ๐Ÿ’ซ

slay on success: she returns zero. ๐Ÿ˜Œ

but on error, she returns -1, and errno gets set so you know what went wrong. ๐Ÿ’€

๐Ÿ™ˆ ERRORS ๐Ÿ™ˆ

  • EFAULT โ€” buf is not valid. like, not valid valid.

๐Ÿ‘‘ VERSIONS ๐Ÿ‘‘

the domainname member (aka the NIS or YP domain name) is a GNU extension, so don't be shocked when other vibes don't have her.

and the length of the fields in the struct? it varies. some operating systems or libraries hardcode a 9 or 33 or 65 or 257. others use SYS_NMLN or _SYS_NMLN or UTSLEN or _UTSNAME_LENGTH. and clearly, using any of those constants is a bad idea โ€” it's giving chaos โ€” so just use sizeof(...) and move on. ๐Ÿงš

SVr4 uses 257, "to support Internet hostnames" โ€” and that's the largest value you're likely to encounter in the wild โ€” no fr.

๐ŸŒˆ STANDARDS ๐ŸŒˆ

POSIX.1-2024. iconic.

๐Ÿ“œ HISTORY ๐Ÿ“œ

POSIX.1-2001, SVr4, 4.4BSD. the lore goes back bestie.

๐Ÿงต C library/kernel differences ๐Ÿงต

over time the utsname structure kept getting bigger, and that led to three successive versions of uname():

  • sys_olduname() (slot __NR_oldolduname)
  • sys_uname() (slot __NR_olduname)
  • sys_newuname() (slot __NR_uname)

the first one used length 9 for all fields. the second used 65. the third also uses 65 but adds the domainname field. and the glibc uname() wrapper function hides all of this from applications โ€” she just invokes the most recent version of the system call that the kernel provides. she's the main character, handling it for you ๐Ÿ’…

๐Ÿ“ NOTES ๐Ÿ“

the kernel has the name, release, version, and supported machine type built in. but flip side: the nodename field is configured by the administrator to match the network โ€” this is what BSD historically calls the "hostname", and it's set via sethostname(2). similarly, the domainname field is set via setdomainname(2). ๐Ÿซถ

part of the utsname info is also accessible via /proc/sys/kernel/{ostype, hostname, osrelease, version, domainname}. iykyk.

๐ŸŽ€ SEE ALSO ๐ŸŽ€


heads up bestie, EFAULT means buf isn't valid, and the array lengths are unspecified so please please please use sizeof(...). not a vibe-killer, just a vibe-protector. ๐Ÿ“

and that's the whole page!! brought to you by Linux man-pages 6.20, dated 2026-02-08. go run uname -a and feel something. mwah ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms