What is the use of the /etc/passwd file in Linux?

In this article, you will learn about What is the use of /etc/passwd file in Linux?

The /etc/passwd file stores essential information, which is required during login, i.e. user account information.

The /etc/passwd is a text file, which contains a list of the system’s account information. Any user can read the information in /etc/passwd file with the help of vi, cat command, But only root users (administrative users) can change the information in it.

vi /etc/passwd 
cat /etc/passwd

The /etc/passwd file is a colon-separated file that contains below information:

/etc/passwd file in linux
passwd file format

1. User name

The username is the name that a user types in when logging into the system. Each such name must be a unique string (that is a sequence of characters). It should be between a minimum of 1 character and a maximum of 32 characters.

2. Encrypted password

The password field originally contained an encrypted login password. However, for security, reasons, the encrypted passwords are now contained on another file, /etc/shadow, that can not be read by ordinary users. The field contains the letter x to indicate that a password has been assigned to the user and is required for authentication. If this field is empty, the user can log in without a password.

3. User ID number (UID)

Each user must be assigned a unique numeric user identification number. So, if it is a root user account then it will be zero (0). And for some other account list, it starts from 1-99. Further UIDs 100-999 available for ordinary and groups. In the case of CentOS 7 or later, UIDs for ordinary users start from 1000.

4. User’s group ID number (GID)

The group ID specifies the user’s principal group identification number. This is usually the same as the user ID but it can be different. The primary group ID stored in /etc/group file.

5. Full name of the user (GECOS) or comment section

It is a comment section. You can type the user full name or you can put any other information here. Also, you can leave it empty. So, It can contain multiple entries, each separated by a comma.

6. User home directory

It is the directory that the user is first in when logging into the system and which contains program and configuration files specific to that user. The default location of the user is /home. So, if this directory does not exist then the user’s directory becomes / and for the root user, it is different, i.e. /root

7. Login shell

The absolute path of a command or shell (/bin/bash). So, typically this is a shell; it does not have to be a shell.

Conclusion

I conclusion, you learned about the /etc/passwd file in Linux. This file is essential because it has information related to users. So, I hope, you understand but if you have any questions, you can ask in the comment section.

One comment

  1. Like!! I blog frequently and I really thank you for your content. The article has truly peaked my interest.

Leave a Reply