3.1 User and Group Management
The Big Three Files
Section titled “The Big Three Files”Authentication in Linux revolves around three plain text files in /etc.
| File | Contains | Permissions |
|---|---|---|
/etc/passwd | User info (Shell, Home dir, UID). | Readable by anyone (644). |
/etc/shadow | Encrypted passwords. | Readable only by root (600/640). |
/etc/group | Group memberships. | Readable by anyone (644). |
(See [[/en/module-2/4-permissions|Permission Management]] for details on 644/600 modes)
User Management
Section titled “User Management”Create, modify, and delete users.
Root Access (su vs sudo)
Section titled “Root Access (su vs sudo)”The root user is the system administrator with unlimited privileges.
sudo (SuperUser DO)
Section titled “sudo (SuperUser DO)”Run a single command with root privileges. Safe and logged.
- Usage:
sudo [command] - Config:
/etc/sudoers(Edit withvisudo).
su (Switch User)
Section titled “su (Switch User)”Switch to another user account (default is root).
su: Switch to root (keeps current environment variables).su -: Switch to root and load root’s environment (recommended).su - anna: Switch to user ‘anna’.
Group Management
Section titled “Group Management”Practice Exercises
Section titled “Practice Exercises”- New Recruit:
- Create a new user
intern. - Assign them a password.
- Verify their entry in
/etc/passwd.
- Create a new user
- Group Work:
- Create a group called
ops. - Add your current user and the
internuser to this group. - Verify with the
groupscommand (e.g.,groups intern).
- Create a group called
- Cleanup:
- Delete the
internuser and their home directory. - Delete the
opsgroup.
- Delete the