File /etc/passwd

dm8ry

Dmitry Romanoff

Posted on December 6, 2022

File /etc/passwd

The /etc/passwd is a plain text-based database that contains information for all user accounts on the Linux system.

Each record in the /etc/passwd file has 7 fields
separated by a colon ( : )

Let’s consider the /etc/passwd file format.

www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
Enter fullscreen mode Exit fullscreen mode

www-data - Registered username.
It is used when a user logs in.
It should be between 1 and 32 characters in length.

x - It indicates an encrypted password. It’s stored in the /etc/shadow file.

33 - It indicates a user identifier.
Each user in Linux must be assigned a user ID (UID).
UID 0 (zero) is reserved for root.
The UIDs 1-99 are reserved for other predefined accounts.
Next UID 100-999 are reserved by system for administrative and system accounts/groups.

33 - It indicates a primary group ID (stored in the file /etc/group).

www-data - It indicates extra information about a user.
Different organizations set different requirements on this field format.
This field is used by a finger command.

/var/www - It sets to a user home directory absolute path.
When a user logged in it will be in this directory.
If this directory doesn’t exist then user directory becomes /

/usr/sbin/nologin - It sets the shell a user is using. Usually it’s a shell.
But it doesn’t have to be a shell.
For example, sysadmin can use the nologin shell, which acts as a replacement shell for the user account.
If the shell is set to /sbin/nologin and the user tries to log in to the Linux system directly, the /sbin/nologin shell closes the connection.

The /etc/passwd file is used by login, ls, who commands.

💖 💪 🙅 🚩
dm8ry
Dmitry Romanoff

Posted on December 6, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related