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 checkingerrnoafter callinggetgid(), 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()andgetegid()system calls, there's a singlegetxgid()system call, and it returns a pair โ the real and effective GIDs together, like a two-for-one deal ๐ - The glibc
getgid()andgetegid()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()andgetegid()system calls supported only 16-bit group IDs. tiny. adorable. limited. ๐ญ - Subsequently, Linux 2.4 added
getgid32()andgetegid32(), supporting 32-bit IDs. glow up โจ - The glibc
getgid()andgetegid()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
- 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