/etc/passwd, what is this file and what is it for?

About the /etc/passwd file

In the next article we will take a quick look at /etc/passwd. This file will store essential information that is required during login on Gnu/Linux systems.. In other words, information related to user accounts will be stored there. The file saves plain text, which will provide useful information for each user account.

The file /etc/passwd you must have general read permission, as many utilities use it to assign an ID to usernames. Write access to this file is limited to the superuser/root account.. The file is owned by root and has 644 permissions. Which means that it can only be modified by root or users with sudo privileges.

A quick look at the /etc/passwd file

The name of the file originates from one of its initial functions. This contained the data used to verify the passwords of user accounts. However, on modern Unix systems, password information is usually stored in a different fileusing shadow passwords or other database implementations.

It can be said that the file /etc/passwd It is a plain text based database, which contains information about all user accounts found in the system.. As we said, it is owned by root, and even though it can only be modified by root or users with sudo privileges, it is also readable by other users on the system.

What is the /etc/passwd file?

One feature to highlight is that it is a simple file of ascii text. East is a configuration file containing details regarding user accounts. Uniquely identifying users is essential and necessary at login time, and that is exactly where Gnu/Linux systems use /etc/passwd.

a user's account

In this plain text file we will find a list of the system accounts, saving from each account useful information such as user ID, group ID, home directory, shell and more. Also, this must have general read permission, as many command utilities use it to assign a user ID to usernames.

Although it is possible to add and manage users directly in this file, it is not recommended to do so, since this action can add errors, which would be a problem. Instead of doing it like this, your thing is to use the commands available for user administration.

What is the use of this file?

There are several different authentication schemes that can be used on Gnu/Linux systems. The most widely used standard scheme is to perform authentication on files /etc/passwd Y /etc/shadow. In the File /etc/passwd the list of system users is stored along with important information about them. Thanks to this file, the system can uniquely identify users, as this is essential and necessary when starting the corresponding session correctly.

The content of the file /etc/passwd determines who can legitimately access the system and what they can do once inside. This is why this file can perhaps be considered the first line of defense for the system to prevent unwanted access. For this reason, it is important to keep it bug and glitch free.

Format of the /etc /passwd file

In the content of this file, we will find the username, the real name, the identification information and the basic information of the account of each user. As we said, this is a text file with one entry per line, and each of these lines represents a user account.

For view your contentusers can use a text editor or a command like the following:

View of the contents of /etc/passwd

cat /etc/passwd

Each line of the file /etc/passwd will contain seven fields separated by dots (:). Typically, the first line describes the root user, followed by the system and normal user accounts. New entries are added at the end.

/etc/passwd file values

Next we are going to see what each of the values ​​that we are going to find in each of the lines of the file means /etc/passwd:

/etc/passwd file values

  1. Username→ East se used when the user logs in. It must be between 1 and 32 characters long.
  2. Password→ The character x will indicate that the encrypted password is stored in the file /etc/shadow.
  3. User ID (UID)→ Each user is assigned a user ID (UID) unique in the system. UID 0 is reserved for root and UIDs 1-99 are reserved for other predefined accounts. The system will reserve other UIDs from 100 to 999 for administrative and system accounts/groups.
  4. group ID (G.I.D.)→ This is the ID of the main group to which the user belongs (stored in the /etc/group file).
  5. User information (GECKOS)→ Here we will find the comment field. In this it is possible to add additional information about the users, such as the full name, the telephone number, etc.
  6. home directory→ Here we will find the absolute path to the user’s “home” directory. If this directory does not exist, the user directory becomes /.
  7. shell→ This is the absolute path of the shell (/bin/bash). Although it might not be a shell as such. If the shell is set to /sbin/nologin and the user tries to log in to the Gnu/Linux system directly, the shell /sbin/nologin will close the connection.

As we have said lines above, except for the password, with any text editor like “vim” or “gedit” and “root” privileges we can change the behavior and configuration of all the users stored in “/etc/passwd”. Although it is also necessary to insist that modifying this file should not be done except in an exceptional case (and knowing what is done), because if something gets corrupted or we delete something in an oversight, we can find ourselves facing a catastrophe, because in this file is the basic root of all the permissions that we use and will use in the system

Add Comment