UNAME(3P)
π hey bestie, welcome to uname(3P) π
okay so this is a page from the POSIX Programmer's Manual (yes, that whole thing, the POSIX one). Real talk though: the Linux implementation of this interface might not match what you're about to read β so if you're on Linux, go peek at the Linux man page for the actual tea, or honestly the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
uname β get the name of the current system π
πΈ SYNOPSIS πΈ
#include <sys/utsname.h>
int uname(struct utsname *name);
π¦ DESCRIPTION π¦
so the uname() function is gonna store info that identifies the current system inside the structure that name points to. like, it fills in the vibes of your machine. π
it uses the utsname structure, which lives in <sys/utsname.h> β that's where it's defined, no cap.
here's the breakdown of what goes where:
sysnameβ this character array gets a string naming the current system. literally the name of your system.nodenameβ this one holds the name of this node within an implementation-defined communications network. (implementation-defined, so like... whatever the implementation says, bestie.)releaseandversionβ these two arrays further identify the operating system.machineβ contains a name that identifies the hardware the system is running on. the actual hardware, not the OS.
and the format of each member? implementation-defined. every single one. that's just how it is. π«Ά
β RETURN VALUE β
- if it works: you get a non-negative value back. slay.
- if it doesn't: you get
-1anderrnogets set to tell you what went wrong.
π ERRORS π
No errors are defined. that's it. that's the whole section. iconic honestly.
the following sections are informative β aka, they're the commentary track, not the rules. π
π EXAMPLES π
None. (crickets. but cute crickets. π¦β¨)
π APPLICATION USAGE π
okay important thing: just because nodename is chillin' in this structure does not mean it's enough info to actually interface with communications networks. it's not sufficient. don't come for me, I'm just the messenger. π
π RATIONALE π
the values of the structure members are not constrained to have any relation to the version of this volume of POSIX.1β2017 that's implemented in your operating system. so don't go reading them like a version number, bestie. if your app needs to know that, it should depend on _POSIX_VERSION and the related constants defined in <unistd.h> instead. that's the move.
also β this volume of POSIX.1β2017 does not define the sizes of the structure's members, and it actually permits them to be different sizes from each other. though, ngl, most implementations just make them all the same size: eight bytes plus one byte for the string terminator. and heads up: that size for nodename is not enough for use with many networks. π
history lesson time π: the uname() function originated in System III, System V, and related implementations β and it does not exist in Version 7 or 4.3 BSD. and in those historical implementations, the values it returns are set at system compile time. wild.
and 4.3 BSD has gethostname() and gethostid() β those return a symbolic name and a numeric value, respectively. there are also related sethostname() and sethostid() functions used to set the values that the other two return. the former functions (the getters) are included in this specification; the latter (the setters) are not. periodt.
π§ FUTURE DIRECTIONS π§
None. β¨
π₯ SEE ALSO π₯
- The Base Definitions volume of POSIX.1β2017,
<sys_utsname.h>
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. so like, in the event of any discrepancy between this version and the original IEEE and The Open Group Standard β the original IEEE and The Open Group Standard is the referee document. it's the final say. no arguments. π
the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
and any typographical or formatting errors that show up in this page are most likely from the conversion of the source files to man page format. to report those errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole thing, bestie!! this lil masterpiece was brought to you by IEEE/The Open Group, 2017, and yes it's literally titled UNAME(3P) π you ate that, go call uname() on something π«Άβ¨
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- 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-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms