Site icon DesignLinux

Understanding the /etc/passwd File Format

etc-passwd-file

The /etc/passwd is a text-based based database that stores the user account information. /etc/passwd file can be modified by root or users with sudo privileges and can be read by all the system users. It is owned by root and has 644 permissions and commonly used for user authentication.

It’s recommended to use the usermod command to modify the user account and useradd command to add new user account. Avoid the modification of the /etc/passwd file by hand.

/etc/passwd Format

The /etc/passwd file contains one entry per line for each user. All the fields are separated by colon (:) symbol and total seven fields per line. Use the cat command to view the content of /etc/passwd file.

cat /etc/passwd
kunj:x:1000:1000:Kunj,,,:/home/kunj:/bin/bash
[--] - [--] [--] [-----] [--------] [--------]
|    |   |    |     |         |        |
|    |   |    |     |         |        +-> 7. Login shell
|    |   |    |     |         +----------> 6. Home directory
|    |   |    |     +--------------------> 5. GECOS
|    |   |    +--------------------------> 4. GID
|    |   +-------------------------------> 3. UID
|    +-----------------------------------> 2. Password
+----------------------------------------> 1. Username

Conclusion

This article explained the information about the /etc/passwd file. The /etc/passwd file contains the information about the system users.

If you have any questions or feedback, feel free to leave a comment.

Exit mobile version