passwd(5)

๐Ÿ’– passwd(5) โ€” the password file, explained by your fave Unix bestie ๐Ÿ’–

okay so real talk: this is a File Formats Manual page, and it's about the passwd file. it's giving "the guest list of your whole system" energy and honestly? iconic. let's get into it ๐Ÿซถ


โœจ NAME โœจ

passwd โ€” the password file. that's it, that's the name, slay.


๐ŸŒธ DESCRIPTION ๐ŸŒธ

The /etc/passwd file is a text file that describes user login accounts for the system. read permission should be allowed for all users โ€” lots of utilities use it, like ls(1), to map user IDs to usernames โ€” but write access? superuser only, bestie. don't let just anyone be editing the guest list ๐Ÿ’…

back in the good old days there was no great problem with this general read permission. everybody could read the encrypted passwords, but the hardware was way too slow to crack a well-chosen password, and ngl the basic assumption used to be that of a friendly user-community. those days are so over. these days many people run some version of the shadow password suite, where /etc/passwd has an 'x' character in the password field, and the encrypted passwords live in /etc/shadow, which is readable by the superuser only. privacy era ๐Ÿ”ฅ

If the encrypted password โ€” whether in /etc/passwd or in /etc/shadow โ€” is an empty string, login is allowed without even asking for a password. ๐Ÿ˜ญ yes fr, no password at all. note that this functionality may be intentionally disabled in applications, or configurable (for example using the "nullok" or "nonull" arguments to pam_unix(8)).

If the encrypted password in /etc/passwd is "*NP*" (without the quotes, bestie โ€” the quotes aren't part of it), the shadow record should be obtained from an NIS+ server. iykyk.

Regardless of whether shadow passwords are used, many system administrators use an asterisk (*) in the encrypted password field to make sure that this user can not authenticate themself using a password. (But see NOTES below โ€” there's a whole plot twist ๐Ÿ‘€.)

If you create a new login, first put an asterisk (*) in the password field, then use passwd(1) to set it. that's the order, don't skip steps ๐ŸŽ€


๐Ÿฆ‹ the seven fields ๐Ÿฆ‹

Each line of the file describes a single user, and contains seven colon-separated fields:

name:password:UID:GID:GECOS:directory:shell

The fields are as follows:

  • name โ€” This is the user's login name. It should not contain capital letters. lowercase only, no cap (literally). ๐Ÿ’€
  • password โ€” This is either the encrypted user password, an asterisk (*), or the letter 'x'. (See pwconv(8) for an explanation of 'x' โ€” that's where the lore lives.)
  • UID โ€” The privileged root login account (superuser) has the user ID 0. zero, the main character of numbers ๐Ÿ‘‘
  • GID โ€” This is the numeric primary group ID for this user. (Additional groups for the user are defined in the system group file; see group(5).)
  • GECOS โ€” This field (sometimes called the "comment field") is optional and used only for informational purposes. Usually, it contains the full username. Some programs (for example, finger(1)) display information from this field.

GECOS stands for "General Electric Comprehensive Operating System", which was renamed to GCOS when GE's large systems division was sold to Honeywell. Dennis Ritchie has reported: "Sometimes we sent printer output or batch jobs to the GCOS machine. The gcos field in the password file was a place to stash the information for the $IDENTcard. Not elegant." not elegant ๐Ÿ˜ญ but historic. we respect the ancestry.

  • directory โ€” This is the user's home directory: the initial directory where the user is placed after logging in. The value in this field is used to set the HOME environment variable. your home base, your little nest ๐ŸŽ€
  • shell โ€” This is the program to run at login (if empty, use /bin/sh). If set to a nonexistent executable, the user will be unable to login through login(1). The value in this field is used to set the SHELL environment variable. choose wisely bestie, this is your whole aesthetic โœจ

๐ŸŒˆ FILES ๐ŸŒˆ

  • /etc/passwd

that's the one. the file. the moment.


โญ NOTES โญ

If you want to create user groups, there must be an entry in /etc/group, or no group will exist. no entry, no group, no exceptions, periodt.

If the encrypted password is set to an asterisk (*), the user will be unable to login using login(1), but may still login using rlogin(1), run existing processes and initiate new ones through rsh(1), cron(8), at(1), or mail filters, etc. ๐Ÿ˜ณ yeah. the asterisk is not the full lockout people think it is.

Trying to lock an account by simply changing the shell field yields the same result and additionally allows the use of su(1). so if you're out here trying to lock an account by editing the shell field โ€” that's not a lock, that's a vibe check that failed. do not rely on it ๐Ÿšจ

๐ŸŽ€ SEE ALSO ๐ŸŽ€

chfn(1), chsh(1), login(1), passwd(1), su(1), crypt(3), getpwent(3), getpwnam(3), group(5), shadow(5), vipw(8)

go read them, they're all bangers, fr fr ๐Ÿ”ฅ


and that's the whole page bestie ๐Ÿ’– this one's from Linux man-pages 6.18, dated 2025-09-21 โ€” so you know it's fresh. now go forth and respect the colon-separated fields. mwah ๐Ÿซถโœจ

๐Ÿ“ฆ where this page comes from