putpwent(3)

✨ putpwent β€” bestie edition ✨

okay so this is putpwent(3), from the Library Functions Manual, and it's literally the "write a password file entry" girlie. tiny function, one job, zero drama. let's get into it πŸ’–


🌸 NAME 🌸

putpwent β€” write a password file entry ✍️


πŸ“š LIBRARY πŸ“š

Standard C library (libc, link it with -lc) 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>

int putpwent(const struct passwd *restrict p, FILE *restrict stream);

πŸ¦‹ Feature Test Macro Requirements for glibc πŸ¦‹

(peep feature_test_macros(7) if you're new here)

putpwent():

  • Since glibc 2.19:
    • _DEFAULT_SOURCE
  • glibc 2.19 and earlier:
    • _SVID_SOURCE
not me having to remember which glibc era you're on before you can even call this 😭

πŸ’… DESCRIPTION πŸ’…

putpwent() writes a password entry β€” that's the struct p you handed it β€” into the file associated with stream. that's it. that's the whole function. iconic minimalism ✨

The passwd structure is defined in <pwd.h> like this, no cap:

struct passwd {
    char    *pw_name;        /* username */
    char    *pw_passwd;      /* user password */
    uid_t    pw_uid;         /* user ID */
    gid_t    pw_gid;         /* group ID */
    char    *pw_gecos;       /* real name */
    char    *pw_dir;         /* home directory */
    char    *pw_shell;       /* shell program */
};

every field is a whole vibe: pw_name is who you are, pw_passwd is the secret, pw_uid is your numeric main-character ID, pw_gid is your group, pw_gecos is your government name fr, pw_dir is where you live, pw_shell is what you run when you log in 🐚


🫢 RETURN VALUE 🫢

  • 0 β€” slay, it worked, success πŸ’–
  • -1 β€” nope, it failed, and errno gets set to tell you why πŸ™ˆ

πŸ’€ ERRORS πŸ’€

  • EINVAL β€” invalid (NULL) argument given. basically you passed it nothing and it said "girl what" 🚫

πŸ‘‘ ATTRIBUTES πŸ‘‘

for what all these terms even mean, go read attributes(7), bestie.

  • Interface: putpwent()
  • Attribute: Thread safety
  • Value: MT-Safe locale
MT-Safe locale, meaning the threading girlies can vibe, but watch your locale. noted. πŸ’…

🌈 STANDARDS 🌈

None. literally none. it's giving "not standardized, we just live here" 😌


⭐ HISTORY ⭐

SVr4. vintage, but make it password-file ✨


πŸ”₯ SEE ALSO πŸ”₯

endpwent(3), fgetpwent(3), getpw(3), getpwent(3), getpwnam(3), getpwuid(3), setpwent(3)


and that's the whole page, bestie!! this dropped in Linux man-pages 6.20, dated 2026-02-08, and yes the putpwent(3) energy is still immaculate. go write that password entry, you got this πŸ’–πŸ¦‹βœ¨

πŸ“¦ 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