Understand Each Entries Of Linux Password (/etc/passwd) File

October 6, 2012 | By
| Reply More

Linux Password File

In Linux, when a user is created (it can be done using ‘useradd’ command), it will update some system files such as /etc/passwd, /etc/shadow and /etc/group. In this article, we will go through the file /etc/passwd which is one of the most important file in Linux. This file contains the essential information for a user to login to the Linux machine. This file can be read by any users but is writable only by the super user-root.

Each system user has a specific line in the /etc/passwd file which describes the username, UID, GID etc.
Each line has the following syntax.

test:x:561:561:Test User:/home/test:/bin/bash

As you can see, there are seven fields separated by a “colon :”. Now, we can see what each field represents.

1. Username

This field defines the username of the user to login. Only local users have entries in passwd file. It should be between 1 to 32 characters.

2. Password (x)

The character “x” in this field represents that the encrypted password is available in /etc/shadow file. The password file doesn’t include the password for security reasons (readable by everybody). The /etc/shadow file is readable only by the root user. If you put * inplace of x then user can't login. If you keep second field blank then user can login without password.

3. UID

Every user created in a Linux machine will have a unique user ID. The UID digit “0” represents “root” and UID 1 to 99 are reserved for other predefined accounts.

4. GID

When a user is created using the command “useradd”, it will also create a primary group for the user in the same name as the “username” (if you didn’t explicitly mention any group name. The field GID represents the unique ID given for the primary group to which the user belongs to. A single user can be a member of multiple groups which can be found from the file “/etc/group”. But, the passwd file will contain the information of the primary group only.

5. User ID Info

This is used as an informational / comment field. It allows you to add extra information about the users such as user’s full name.

6. Home Directory

It represents the absolute path to the user's home directory. If this directory does not exist the '/' directory becomes the users home directory.

7. Shell

The absolute path of command or shell (/bin/bash). Typically this field contain information about user's default shell.
The default permission of the /etc/passwd file is 644, so that any user can read the information from /etc/passwd file.

-rw-r--r-- 1 root root 2659 Sep 10 12:25 /etc/passwd


Tagged With :

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.