The /etc/passwd is a text-based based database that stores the user account information. /etc/passwd file can be modified by root or users with sudo privileges and can be read by all the system users. It is owned by root and has 644 permissions and commonly used for user authentication.
It’s recommended to use the usermod
command to modify the user account and useradd
command to add new user account. Avoid the modification of the /etc/passwd
file by hand.
/etc/passwd Format
The /etc/passwd
file contains one entry per line for each user. All the fields are separated by colon (:
) symbol and total seven fields per line. Use the cat command to view the content of /etc/passwd
file.
cat /etc/passwd
kunj:x:1000:1000:Kunj,,,:/home/kunj:/bin/bash
[--] - [--] [--] [-----] [--------] [--------]
| | | | | | |
| | | | | | +-> 7. Login shell
| | | | | +----------> 6. Home directory
| | | | +--------------------> 5. GECOS
| | | +--------------------------> 4. GID
| | +-------------------------------> 3. UID
| +-----------------------------------> 2. Password
+----------------------------------------> 1. Username
- Username – It’s a unique name used to login on system. The maximum length of the username is restricted to 32 characters.
- Password – The value x indicates that the user’s password is encrypted and stored in
/etc/shadow
file. - UID – The system provide a unique id to each user which is used by system to identify the user.
- GID – GID is user’s group identifier number, referring to the user’s primary group. When a user creates a file, the file’s group is set to this group. Typically, the name of the group is the same as the name of the user.
- GECOS – This fields contains the additional information about the user such as full name, phone number, etc.
- Home directory – The absolute path to the directory the user will be in when they log in.
- Login shell – It’s absolute path to the user’s login shell. This is the shell that is started when the user logs into the system. Bash is the default login shell in most of Linux distribution.
Conclusion
This article explained the information about the /etc/passwd
file. The /etc/passwd file contains the information about the system users.
If you have any questions or feedback, feel free to leave a comment.