initgroups(3)
๐ initgroups โ the glibc manual page, but make it cute ๐
okay bestie, so this one lives in the Library Functions Manual (section 3, the libc girlies ๐ธ). It's called initgroups, and it's the little function that sorts out your supplementary group access list. Yes it's giving sysadmin. Yes it's important. Let's go ๐ซถ
โจ NAME โจ
initgroups โ initialize the supplementary group access list
๐ LIBRARY ๐
Standard C library (libc, -lc)
๐ SYNOPSIS ๐
#include <sys/types.h>
#include <grp.h>
int initgroups(const char *user, gid_t group);
๐ Feature Test Macro Requirements for glibc ๐
(see feature_test_macros(7))
initgroups():
- Since glibc 2.19:
_DEFAULT_SOURCE - glibc 2.19 and earlier:
_BSD_SOURCE
periodt, those are the macros you need, no cap ๐
๐ฆ DESCRIPTION ๐ฆ
okay so here's the vibe. initgroups() initializes the group access list. The way it does that is it reads the group database โ that's /etc/group, iconic file, we love her โ and it uses all the groups of which user is a member. So it's basically doing your group homework for you ๐โจ
And then, as a lil bonus treat, the additional group group is also added to the list. Extra. Very main character of it, honestly ๐
โ ๏ธ heads up bestie: the user argument must be non-NULL. Like, must. Don't be sending a NULL in there, that's not the move ๐ซ
๐ RETURN VALUE ๐
- On success:
initgroups()returns0๐ slay - On error: it returns
-1, and errno gets set to tell you what went wrong (iykyk, always check your errno)
๐ ERRORS ๐
ENOMEMโ not enough memory to allocate the group information structure ๐ญ the malloc girlies are strugglingEPERMโ the calling process has insufficient privilege. Peep the underlying system callsetgroups(2)for the full tea โ
๐ FILES ๐
/etc/groupโ the group database file, the source of truth, the blueprint ๐
โญ ATTRIBUTES โญ
For an explanation of the terms used in this section, see attributes(7).
- Interface:
initgroups() - Attribute: Thread safety
- Value:
MT-Safe locale
no table bestie, we do bullets here, but the facts are the facts: initgroups() is thread-safe with respect to locale ๐ง
๐ STANDARDS ๐
None. Literally none. It's just out here doing its own thing, unstandardized and unbothered ๐
๐ธ HISTORY ๐ธ
SVr4, 4.3BSD. Ancient. Vintage. A true icon of the ages ๐๏ธโจ
๐ฅ SEE ALSO ๐ฅ
and that's the whole page bestie, go forth and initialize those groups ๐ซถ๐โญ
signed off with love: this is from Linux man-pages 6.20, dated 2026-02-08 โ catch you in the next manpage, mwah ๐๐
๐ฆ 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, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms