/etc/passwd

Updated: April 19, 2023

This file stores information about users.

Each line in /etc/passwd is in this format:

username:has_pw:userid:group:comment:homedir:shell

The fields are separated by colons and include:

username
The user's login name. This can contain any characters except a colon (:), but you should probably avoid any of the shell's special characters. For more information, see Quoting special characters in Using the Command Line.
has_pw

This field must be empty or x. If x, the user's hashed password is in /etc/shadow.

It's not recommended to leave it empty, as it means one of two things, depending on options given to other components: a password is not required to authenticate, or you cannot successfully authenticate.

If the pam_qnx.so PAM module is used for authentication, then it's necessary to use the nullok option for it to permit authentication without a password. Without this option, any attempt to authenticate is disallowed. If nullok is used, authentication when using login or su is permitted without a password. In the case of ssh, the use of nullok with pam_qnx.so is insufficient. You must also set the sshd config option PermitEmptyPasswords to yes.

userid
The numeric user ID.
group
The numeric group ID.
comment
A free-form comment field that usually contains at least the user's real name; this field must not contain a colon.
homedir
The user's home directory.
shell
The initial command to start after login. The default is /bin/sh. If you don't want to allow a user to log in, specify the path to a binary such as false that will exit when run. Alternatively, you can use a non-existent path such as NO_LOGINS.
Note: You can't provide any arguments to the shell.

Here's a sample entry from /etc/passwd:

fred:x:290:120:Fred L. Jones:/home/fred:/bin/sh