putgrent(3)

🌸 putgrent(3) β€” Library Functions Manual 🌸

okay bestie, so this one is putgrent, from the Library Functions Manual, and it lives in the Standard C library (libc, -lc). it's the glow-up twin of writing group entries to a file. let's get into it πŸ’…


✨ NAME ✨

putgrent β€” write a group database entry to a file

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc)

🫢 SYNOPSIS 🫢

#define _GNU_SOURCE         /* See feature_test_macros(7) */
#include <grp.h>

int putgrent(const struct group *restrict grp, FILE *restrict stream);

πŸ’– DESCRIPTION πŸ’–

so putgrent() is literally the counterpart for fgetgrent(3). the way that it writes the content of the struct group you hand it into the stream. that's the whole vibe. πŸ¦‹

heads up bestie: the list of group members must be NULL-terminated or NULL-initialized. no half-finished lists, okay? that's the rule and we respect it. πŸ’€

and the struct group is defined like this, no cap:

struct group {
    char   *gr_name;      /* group name */
    char   *gr_passwd;    /* group password */
    gid_t   gr_gid;       /* group ID */
    char  **gr_mem;       /* group members */
};

⭐ RETURN VALUE ⭐

the function returns zero on success, and a nonzero value on error. that's it, that's the tea. ✨

πŸ‘‘ ATTRIBUTES πŸ‘‘

for an explanation of the terms used in this section, see attributes(7).

  • putgrent() β€” Thread safety: MT-Safe

periodt. it's MT-Safe, she's safe, she's fine, she's iconic. πŸŽ€

🌈 STANDARDS 🌈

GNU. (iykyk, it's a GNU thing πŸ’œ)

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie!! this one's from Linux man-pages 6.20, dated 2026-02-08 πŸ“πŸ’– mwah, go forth and write those group entries responsibly, ily, bye!! 🧚✨

πŸ“¦ 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: GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms