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, anderrnogets 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
- 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