/etc/passwd file in linux is a text file that contains a list of the system’s accounts which is required during login. It contains essential information like user ID, group ID, home directory, shell, etc.
/etc/passwd contains one entry per line for each user (or user account) of the system. All fields are separated by a colon (:) symbol. There are total of seven fields per line.
Now, let’s elaborate the fields for the entries
- Username: Username is needed for user login. It should be between 1 and 32 characters.
- Password: Password is stored encrypted in /etc/shadow file which is indicated by x character above.
- User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for administrative and system accounts/groups.
- Group ID (GID): Group ID of a user which is stored in /etc/group file
- User ID Info: This is the comment field which allows you to add extra information about the users such as user’s full name, phone number etc. This field is used by finger command.
- Home Directory: The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory becomes /
- Command/Shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell but that does not mean it has to be a shell.