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, and POSIX.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() and geteuid() ๐ŸŽ€ and that's the version we still vibe with
  • the original Linux getuid() and geteuid() system calls only supported 16-bit user IDs ๐Ÿ™ˆ
  • after that, Linux 2.4 added getuid32() and geteuid32(), which support 32-bit IDs ๐Ÿ”ฅ glow-up fr fr
  • the glibc getuid() and geteuid() 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() and geteuid() system calls, there's a single getxuid() system call that returns a pair of real and effective UIDs
  • and yep, the glibc getuid() and geteuid() 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms