Short Tutorial: Understanding /etc/passwd File

The /etc/passwd file stores information related to available user accounts on the operating system. This blog explains the basics of the /etc/passwd file available in Linux-based operating systems.

How to check permissions of /etc/passwd file

You can check permissions of /etc/passwd by using ls utility.

ls -l /etc/passwd

Else, you can also use stat command to know about the file.

stat /etc/passwd

/etc/passwd Format

Each line in /etc/passwd file represents a user account on the Linux system. You can view the passed file by any editor. Here, I have used cat utility to view passwd file. Remember, you are able to view passwd file only if you are root or sudo privilege.

cat /etc/passwd

We have just take one line below from the output to understand the format:

root:x:0:0:root:/root:/usr/bin/zsh

1234567
rootx00root/root/usr/bin/zsh
UsernameEncrypted passwordUser ID (UID)User's group ID (GID)Info of the user (GECOS)User home directoryLogin shell
  1. Username - User's login. Must not have capital letters
  2. Encrypted password - x here denotes password is encrypted
  3. User ID (UID) - User ID 0 denote the root login account
  4. User's group ID (GID) - primary group ID for this user
  5. Info of the user (GECOS) - optional and provide information related to a user. For information, GECOS stands for "General Electric Comprehensive Operating System".
  6. User home directory - user's home directory. It contains the user's files and configurations.
  7. Login shell - It denotes the absolute path to the user’s login shell

For creating user groups, please ensure entry in /etc/group, otherwise, no group will exist.

Should we edit /etc/passwd?

Unless you know what are you doing, till then no need to change or edit passwd file. Read more tutorials and man page, understand more about this command. Once you are confident enough, then only edit passwd file.

Conclusion

The /etc/passwd file keeps monitoring all available users on the system. Generally, you need to read this file to understand the number of users who are able to log in to the system.

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

You may also like...

Leave a Reply

Your email address will not be published.