getgid(2)

๐Ÿ’– getgid(2) โ€” the System Calls Manual page, but make it make sense โœจ

okay bestie, welcome to section 2 of the manual โ€” the System Calls Manual, to be precise โ€” and today we're getting into getgid. it's short, it's sweet, it's giving "who even am I" but for groups. let's go ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŒธ

getgid, getegid โ€” get group identity ๐Ÿ‘‘


๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc) โ€” yes queen, you gotta link the libc, always


โœจ SYNOPSIS โœจ

#include <unistd.h>

gid_t getgid(void);
gid_t getegid(void);

look at them. two little functions. zero arguments. no cap. ๐Ÿ’…


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

  • getgid() โ€” hands you back the real group ID of the calling process. that's your actual, true, main-character group identity, no makeup on ๐Ÿ’–
  • getegid() โ€” hands you back the effective group ID of the calling process. that's the one the kernel actually checks when you try to do stuff. it's giving "what you're wearing to the permission party" โœจ

both return a gid_t, and both take void, so you literally cannot pass anything wrong to them. icon behavior fr fr ๐Ÿ™ˆ


๐Ÿ’€ ERRORS ๐Ÿ’€

not a single one. these functions are always successful and never modify errno. no drama, no failure, no chaos. they simply ate and left no crumbs ๐Ÿ˜ญ๐Ÿ‘‘

ngl if you're out here checking errno after calling getgid(), bestie... that's not the vibe. there's nothing to check. it's fine. it's always fine.

๐ŸŒˆ VERSIONS ๐ŸŒˆ

okay so this is the one little plot twist in our story ๐ŸŒ€

  • On Alpha, instead of a pair of getgid() and getegid() system calls, there's a single getxgid() system call, and it returns a pair โ€” the real and effective GIDs together, like a two-for-one deal ๐Ÿ’…
  • The glibc getgid() and getegid() wrapper functions transparently deal with this. so you don't have to do a thing. slay.
  • For the details regarding register mapping, go peek at syscall(2) ๐Ÿงš

โญ STANDARDS โญ

POSIX.1-2024. it's official, it's standardized, it's certified bestie behavior ๐ŸŽ€


๐ŸŽ€ HISTORY ๐ŸŽ€

  • 4.3BSD, POSIX.1-1988 โ€” the origin story, we love a legacy ๐Ÿ‘‘
  • The original Linux getgid() and getegid() system calls supported only 16-bit group IDs. tiny. adorable. limited. ๐Ÿ˜ญ
  • Subsequently, Linux 2.4 added getgid32() and getegid32(), supporting 32-bit IDs. glow up โœจ
  • The glibc getgid() and getegid() wrapper functions transparently deal with the variations across kernel versions. so again โ€” you worry about nothing, the wrappers handle the lore ๐Ÿซถ

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


that's the whole page bestie, we did it, we understood group identity, we did NOT touch errno, and we moved on with our lives ๐Ÿ’œ

Linux man-pages 6.20 ยท 2026-02-08 โ€” mwah, kiss the manual goodbye, ily, go check your gids ๐Ÿ’…๐Ÿ’–

๐Ÿ“ฆ 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