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,EFAULTmeans buf isn't valid, and the array lengths are unspecified so please please please usesizeof(...). 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
- Copyright 2001, Andries E. Brouwer <aeb@cwi.nl>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms