The /etc/passwd file contains basic user account information:
# View the file
cat /etc/passwd
# Format: username:x:UID:GID:GECOS:home_directory:shell
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
john:x:1000:1000:John Doe,,,:/home/john:/bin/bash
x (password stored in /etc/shadow)The /etc/shadow file contains encrypted passwords and password policies:
# View shadow file (requires root)
sudo cat /etc/shadow
# Format: username:encrypted_password:last_change:min:max:warn:inactive:expire
root:$6$randomsalt$encryptedpassword:19000:0:99999:7:::
john:$6$anothersalt$anotherpassword:19500:0:99999:7:::
# View group file
cat /etc/group
# Format: group_name:x:GID:member_list
root:x:0:
adm:x:4:syslog,john
sudo:x:27:john,alice
john:x:1000:
x (group passwords rarely used)# Check user ID and groups
id
id username
# Check current user
whoami
# Check user information
finger username # If finger is installed
getent passwd username
# Check group membership
groups
groups username
# Check who's logged in
who
w
last # Login history
Next: → Creating And Managing Users
Previous: ← Introduction To Users And Groups
Lesson Home: ↑ Lesson 9: Users & Groups
Course Home: ⌂ Introduction to Linux