passwd man page
passwd — password file
The /etc/passwd file is a text file that describes user login accounts for the system. It should have read permission allowed for all users (many utilities, like ls(1) use it to map user IDs to usernames), but write access only for the superuser.
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 too slow to crack a well-chosen password, and moreover the basic assumption used to be that of a friendly user-community. 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 are in /etc/shadow, which is readable by the superuser only.
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. Note that this functionality may be intentionally disabled in applications, or configurable (for example using the "nullok" or "nonull" arguments to pam_unix.so).
If the encrypted password in /etc/passwd is "*NP*" (without the quotes), the shadow record should be obtained from an NIS+ server.
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 him- or herself using a password. (But see Notes below.)
If you create a new login, first put an asterisk (*) in the password field, then use passwd(1) to set it.
Each line of the file describes a single user, and contains seven colon-separated fields:
The field are as follows:
This is the user's login name. It should not contain capital letters.
This is either the encrypted user password, an asterisk (*), or the letter 'x'. (See pwconv(8) for an explanation of 'x'.)
The privileged root login account (superuser) has the user ID 0.
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)).
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."
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.
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.
If you want to create user groups, there must be an entry in /etc/group, or no group will exist.
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. Trying to lock an account by simply changing the shell field yields the same result and additionally allows the use of su(1).
chfn(1), chsh(1), login(1), passwd(1), su(1), crypt(3), getpwent(3), getpwnam(3), group(5), shadow(5), vipw(8)
This page is part of release 4.16 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
aliases.opensmtpd(5), authconfig(8), chage(1), chfn(1), chsh(1), credentials(7), crypt(3), crypt(5), crypt_gensalt(3), darcs(1), dash(1), environ(7), ext_unix_group_acl(8), fgetpwent(3), ftpusers(5), getgrouplist(3), getpw(3), getpwent(3), getpwent_r(3), getpwnam(3), groff_mdoc(7), group(5), grpck(8), libbind_irs.conf(5), login(1), login.defs(5), lslogins(1), mdoc.samples(7), mknetid(8), mkpasswd(1), newusers(8), nologin(8), nscd(8), pam_pwquality(8), postconf(1), pwck(8), pwqcheck(1), pwquality(3), pwquality.conf(5), rpc.yppasswdd(8), shadow(5), sk(3), slapd.backends(5), slapd-passwd(5), smbpasswd(5), sssd-files(5), sudo(8), systemd.exec(5), userhelper(8), userinfo(1), vipw(8), winbindd(8), yppasswd(1).