group_member(3)
π group_member(3) β the "wait, am I in this group??" function π
okay bestie, so this one's from the Linux man-pages crew (Library Functions Manual, no big deal) and it's genuinely one of the cutest little gut-check functions in the whole libc. let's get into it π«Ά
β¨ NAME β¨
group_member β test whether a process is in a group
like. that's it. that's the whole job. she checks if you are in a group. iconic behaviour honestly π
πΈ LIBRARY πΈ
Standard C library (libc, -lc)
so you don't even gotta link anything special. she's just there. free real estate π
π¦ SYNOPSIS π¦
#include <unistd.h>
int group_member(gid_t gid);
π Feature Test Macro Requirements for glibc (see feature_test_macros(7)): π
group_member():
_GNU_SOURCE
β οΈ bestie listen β if you don't define _GNU_SOURCE before your includes, glibc is gonna act like she doesn't know you. define it. do it. no cap. π
π DESCRIPTION π
The group_member() function tests whether any of the caller's supplementary group IDs (as returned by getgroups(2)) matches gid.
so like β the way that this works is she goes through all your supplementary group IDs, the whole squad, the ones getgroups(2) hands over, and she's like "hey, is gid in here??" and if yeah, she's happy πβ¨
note that word supplementary bestie, that's the vibe check she's doing. she's checking the extra groups, the friend-group memberships, not tryna reinvent your whole identity. periodt. π
π RETURN VALUE π
- returns nonzero if any of the caller's supplementary group IDs matches gid β slay, you're in π
- returns zero otherwise β not your group, sorry babe π
no -1, no errno drama. just yes/no energy. very demure, very mindful. πΈ
β STANDARDS β
- GNU.
yeah she's a GNU girlie, glibc-core, not POSIX. if you're porting somewhere else, don't count on her showing up. iykyk π
π SEE ALSO π
go read these next bestie, the whole group-lore extended universe is right there ππ¦
okay that's the whole page!! and for the cute sign-off: this lil' beauty comes from Linux man-pages 6.20, dated 2026-02-08, and yes that's the version and date right there in the footer, we didn't skip it, we cherished it πβ¨π
now go define _GNU_SOURCE and call group_member() on someone. respectfully. π«Άπ
π¦ 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 2014, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms