/etc/passwd: Explanation & Insights

User account information

The file /etc/passwd is a text file that stores user account information on a Unix-like operating system. It stores each user's account information, including their user ID, group ID, home directory, and shell, on a separate line in the file. The file is used by the system to map user names to user ID numbers, and to determine what resources and privileges each user has on the system.

The /etc/passwd file is typically world-readable, which means that any user on the system can view the contents of the file. However, only the root user has the permission to modify the file.

Here is an example of what a line in the /etc/passwd file might look like:


These are the different fields:

  • username: The name of the user account.
  • x: An placeholder for the user's encrypted password. In modern systems, the password is typically stored in a separate file called /etc/shadow.
  • UID: The user ID number of the user account.
  • GID: The group ID number of the user account.
  • GECOS: A field that can be used to store additional information about the user, such as the user's full name and contact information.
  • home_directory: The path to the user's home directory.
  • login_shell: The path to the user's preferred shell, which is the program that runs when the user logs in to the system.

It's important to note that the /etc/passwd file only stores information about user accounts and does not contain any actual passwords. Instead, the passwords are stored in a separate file called /etc/shadow, which is only accessible to the root user.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA