| 1 |
'\" t |
| 2 |
.\" Copyright 1993, David Metcalfe <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH putpwent 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
putpwent \- write a password file entry |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <stdio.h> |
| 16 |
.B #include <sys/types.h> |
| 17 |
.B #include <pwd.h> |
| 18 |
.P |
| 19 |
.BI "int putpwent(const struct passwd *restrict " p \ |
| 20 |
", FILE *restrict " stream ); |
| 21 |
.fi |
| 22 |
.P |
| 23 |
.RS -4 |
| 24 |
Feature Test Macro Requirements for glibc (see |
| 25 |
.BR feature_test_macros (7)): |
| 26 |
.RE |
| 27 |
.P |
| 28 |
.BR putpwent (): |
| 29 |
.nf |
| 30 |
Since glibc 2.19: |
| 31 |
_DEFAULT_SOURCE |
| 32 |
glibc 2.19 and earlier: |
| 33 |
_SVID_SOURCE |
| 34 |
.fi |
| 35 |
.SH DESCRIPTION |
| 36 |
The |
| 37 |
.BR putpwent () |
| 38 |
function writes a password entry from the |
| 39 |
structure |
| 40 |
.I p |
| 41 |
in the file associated with |
| 42 |
.IR stream . |
| 43 |
.P |
| 44 |
The |
| 45 |
.I passwd |
| 46 |
structure is defined in |
| 47 |
.I <pwd.h> |
| 48 |
as follows: |
| 49 |
.P |
| 50 |
.in +4n |
| 51 |
.EX |
| 52 |
struct passwd { |
| 53 |
char *pw_name; /* username */ |
| 54 |
char *pw_passwd; /* user password */ |
| 55 |
uid_t pw_uid; /* user ID */ |
| 56 |
gid_t pw_gid; /* group ID */ |
| 57 |
char *pw_gecos; /* real name */ |
| 58 |
char *pw_dir; /* home directory */ |
| 59 |
char *pw_shell; /* shell program */ |
| 60 |
}; |
| 61 |
.EE |
| 62 |
.in |
| 63 |
.SH RETURN VALUE |
| 64 |
The |
| 65 |
.BR putpwent () |
| 66 |
function returns 0 on success. |
| 67 |
On failure, it returns \-1, and |
| 68 |
.I errno |
| 69 |
is set to indicate the error. |
| 70 |
.SH ERRORS |
| 71 |
.TP |
| 72 |
.B EINVAL |
| 73 |
Invalid (NULL) argument given. |
| 74 |
.SH ATTRIBUTES |
| 75 |
For an explanation of the terms used in this section, see |
| 76 |
.BR attributes (7). |
| 77 |
.TS |
| 78 |
allbox; |
| 79 |
lbx lb lb |
| 80 |
l l l. |
| 81 |
Interface Attribute Value |
| 82 |
T{ |
| 83 |
.na |
| 84 |
.nh |
| 85 |
.BR putpwent () |
| 86 |
T} Thread safety MT-Safe locale |
| 87 |
.TE |
| 88 |
.SH STANDARDS |
| 89 |
None. |
| 90 |
.SH HISTORY |
| 91 |
SVr4. |
| 92 |
.SH SEE ALSO |
| 93 |
.BR endpwent (3), |
| 94 |
.BR fgetpwent (3), |
| 95 |
.BR getpw (3), |
| 96 |
.BR getpwent (3), |
| 97 |
.BR getpwnam (3), |
| 98 |
.BR getpwuid (3), |
| 99 |
.BR setpwent (3) |