Short Tutorial: Understanding /etc/passwd File
The /etc/passwd file stores information related to available user accounts on the operating system. This blog explains the basics of the /etc/passwd file available in Linux-based operating systems.
How to check permissions of /etc/passwd file
You can check permissions of /etc/passwd by using ls utility.
ls -l /etc/passwd
Else, you can also use stat command to know about the file.
Each line in /etc/passwd file represents a user account on the Linux system. You can view the passed file by any editor. Here, I have used cat utility to view passwd file. Remember, you are able to view passwd file only if you are root or sudo privilege.
We have just take one line below from the output to understand the format:
|Username||Encrypted password||User ID (UID)||User's group ID (GID)||Info of the user (GECOS)||User home directory||Login shell|
- Username - User's login. Must not have capital letters
- Encrypted password - x here denotes password is encrypted
- User ID (UID) - User ID 0 denote the root login account
- User's group ID (GID) - primary group ID for this user
- Info of the user (GECOS) - optional and provide information related to a user. For information, GECOS stands for "General Electric Comprehensive Operating System".
- User home directory - user's home directory. It contains the user's files and configurations.
- Login shell - It denotes the absolute path to the user’s login shell
For creating user groups, please ensure entry in /etc/group, otherwise, no group will exist.
Should we edit /etc/passwd?
Unless you know what are you doing, till then no need to change or edit passwd file. Read more tutorials and man page, understand more about this command. Once you are confident enough, then only edit passwd file.
/etc/passwd file keeps monitoring all available users on the system. Generally, you need to read this file to understand the number of users who are able to log in to the system.
Subscribe us to receive more such articles updates in your email.
If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!
Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.