Explained /etc/passwd file in Linux with Examples

/etc/passwd file in Linux Explained with Examples

passwd is a command on Unix, Plan 9, Inferno, and most Unix-like operating systems used to change a user’s password. The password entered by the user is run through a key derivation function to create a hashed version of the new password, which is saved. Only the hashed version is stored; the entered password is not saved for security reasons.

What is /etc/passwd File in Linux


When the user logs on, the password entered by the user during the logs on process is run through the same key derivation function and the resulting hashed version is compared with the saved version. If the hashes are identical, the entered password is considered to be correct, and the user is authenticated.

The passwd command may be used to change passwords for local accounts, and most systems can also be used to change passwords managed in a distributed authentication mechanism such as NIS, Kerberos, or LDAP.
Also Watch this “/etc/passwd file in Linux Explained with Examples” Tutorial video.

Password File

The /etc/passwd file is a text-based database of information about users that may log into system or other operating system user identities that own running processes.

In many operating systems this file is just of many possible back-end for the more general passwd name service.

The file’s name originates from one of its initial functions as it contained the data used to verify the password of users accounts. However, on modern Unix systems the security-sensitive password information is instead often stored in a different file using shadow password, or other database implementations.

The /etc/passwd file typically has file system permissions that allow it to be readable by all users of the system, although it may only be modified by the superuser or by using a few special purpose privileged commands.

The /etc/passwd file is a text file with one record per line, each describing a user account.

Each Record consists of seven fields separated by colons, The ordering of the records within the file is generally unimportant. An example record may be: The fields, in order from left to right, are:

  1. User name: the string a user would type in when logging into the operating system: the log name. Must be unique across users listed in the file.
  2. Password  : Information used to validate a user’s password; in most modern uses, this field is usually set to “x” with the actual password information being stored in a separate shadow password file. On Linux systems, setting this field to an asterisk is a common way to disable direct logins to an account while still preserving its name, while another possible value is “NP” which indicates to use an NIS server to obtain the password. Without password shadowing in effect, this field would typically contain a cryptographic hash of user’s password.
  3. UID (user identifier number), used by the operating system for internal purposes. It need not be unique.
  4. GID (group identifier number), which identifies the primary group of the user; all files that are created by this user may initially be accessible to this group.
  5. Comment field, commentary that describes the person or account. Typically, this is a set of comma-separated values including the user’s full name and contact details.
  6. User home directory: Path to the user’s home directory.
  7. Default shell: Program that is started every time the user logs into the system. For an interactive user, this is usually one of the system’s command line interpreters.
Note: passwd is a tool on most Unix and Unix-like operating systems used to change a user’s password. The /etc/passwd file is owned by the root user and and user can read, but only the root user has writable permissions,/etc/passwd file holding the user related information.

Leave your message if anything missed and we appreciate your comments.

mukesh.thakur87: