getuid(2)
๐ getuid โ bestie, let's talk about who you are ๐
okay so this page is getuid(2) from the System Calls Manual, and it's literally the "who am I" of Unix ๐ช no cap, it's a whole vibe check for your process's identity.
โจ NAME โจ
getuid, geteuid โ get user identity ๐ซถ
๐ LIBRARY ๐
Standard C library โ that's libc, and you link it with -lc like always ๐
๐ธ SYNOPSIS ๐ธ
#include <unistd.h>
uid_t getuid(void);
uid_t geteuid(void);
two lil functions, zero arguments, both handing you back a uid_t. iconic behavior honestly ๐
๐ฆ DESCRIPTION ๐ฆ
so like. every process has identities ok and these two functions are how you peek at them ๐
getuid()โ returns the real user ID of the calling process ๐ซถgeteuid()โ returns the effective user ID of the calling process โจ
that's it. that's the whole function. it's giving "short and sweet and ate" ๐
๐ ERRORS ๐
bestie these functions are literally always successful. always. never once have they failed and they never modify errno.
no error codes, no drama, no 3am debugging. it's the one syscall that would never do you dirty ๐ญ๐ซถ
๐ STANDARDS ๐
POSIX.1-2024 โ certified, standardized, fully that girl ๐
๐ HISTORY ๐
storytime, sit down ๐ง
4.3BSD, andPOSIX.1-1988โ that's where this all comes from ๐- in UNIX V6 the
getuid()call was a whole combo deal: it returned(euid << 8) + uid๐ณ both IDs crammed into one value, wild - then UNIX V7 said "no actually" and introduced the separate calls
getuid()andgeteuid()๐ and that's the version we still vibe with - the original Linux
getuid()andgeteuid()system calls only supported 16-bit user IDs ๐ - after that, Linux 2.4 added
getuid32()andgeteuid32(), which support 32-bit IDs ๐ฅ glow-up fr fr - the glibc
getuid()andgeteuid()wrapper functions transparently deal with all those variations across kernel versions โ so you don't have to think about it, you just get your answer ๐ - special case alert ๐จ on Alpha, instead of a pair of
getuid()andgeteuid()system calls, there's a singlegetxuid()system call that returns a pair of real and effective UIDs - and yep, the glibc
getuid()andgeteuid()wrappers transparently deal with that too ๐ซถ - if you wanna get into the register mapping details for that, go see
syscall(2)๐
๐ SEE ALSO ๐
ok real talk: these are the safest, most well-behaved calls on the whole system. no errno, no failure, no notes. use them and go be your main character self โจ
and that's the page bestie!! this came from Linux man-pages 6.20, dated 2026-02-08 โ mwah, thank u to whoever maintains these, we love u ๐๐๐ฆ periodt ๐
๐ฆ 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 1993, Rickard E. Faith <faith@cs.unc.edu>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms