These are important Linux system files used for:
- User management
- Authentication
- Password storage
- Group permissions
1. /etc/passwd
Purpose
Stores basic user account information.
View File
cat /etc/passwd
Example Entry
aryanโ1001:1001:Aryan:/home/aryan:/bin/bash
Fields Explanation
| Field | Meaning |
|---|---|
| aryan | Username |
| x | Password stored in /etc/shadow |
| 1001 | User ID (UID) |
| 1001 | Group ID (GID) |
| Aryan | Comment/full name |
| /home/aryan | Home directory |
| /bin/bash | Default shell |
Important Notes
UID Meaning
| UID | Purpose |
|---|---|
| 0 | Root user |
| 1-999 | System users |
| 1000+ | Normal users |
Real-World Usage
Check User Shell
grep admin /etc/passwd - Her the admin is username
2. /etc/shadow
Purpose
Stores encrypted passwords and password policies.
Very sensitive file.
View File
Only root can access:
sudo cat /etc/shadow
Example Entry
aryan:$6$abcxyzhashedpassword:19800:0:99999:7:::
Fields Explanation
| Field | Meaning |
|---|---|
| aryan | Username |
| $6$... | Encrypted password |
| 19800 | Last password change |
| 0 | Minimum password age |
| 99999 | Maximum password age |
| 7 | Warning days before expiry |
Password Hash Types
| Prefix | Algorithm |
|---|---|
| $1$ | MD5 |
| $5$ | SHA-256 |
| $6$ | SHA-512 |
Security Importance
/etc/shadow permissions:
ls -l /etc/shadow
Usually:
- r-------- root root
Only root can read it.
Real-World Usage
Check Password Expiry
sudo chage -l vagrant - vagrant is username.
3. /etc/group
Purpose
Stores group information.
Groups help manage permissions for multiple users.
View File
cat /etc/group
Example Entry
docker:x:999:aryan
Fields Explanation
| Field | Meaning |
|---|---|
| docker | Group name |
| x | Group password placeholder |
| 999 | Group ID (GID) |
| aryan | Group members |
Real-World Usage
Check User Groups
groups aryan - aryan is group name.
Common Linux Groups
| Group | Purpose |
|---|---|
| sudo | Administrative access |
| docker | Docker permissions |
| www-data | Web server user |
| wheel | Admin group (RHEL/CentOS) |
Important Commands
Show Current User
whoami
Show User ID
id
Add User
sudo useradd devuser
Set Password
sudo passwd devuser
Add User to Group
sudo usermod -aG docker vagrant
Real-World DevOps Example
Give Docker Permission
sudo usermod -aG docker aryan
Without this:
docker ps
may fail with permission error.
Security Importance
| File | Importance |
|---|---|
| /etc/passwd | User account info |
| /etc/shadow | Secure password storage |
| /etc/group | Permission management |
Best Practices
- Never manually edit /etc/shadow incorrectly
- Use vipw for safe editing
- Limit sudo access
- Use strong password policies
- Regularly audit groups and users
Top comments (0)