Summary of "sudo = POWER!! (managing users in Linux) // Linux for Hackers // EP4"
Brief summary
Hands-on tutorial (Linux for Hackers, Ep.4) covering Linux user and group management using a browser lab from Hack The Box Academy. An Avengers/Thanos story is used as a narrative device to demonstrate creating, modifying, and deleting users/groups and granting sudo (superuser) privileges.
Core technical concepts
- Users and accounts
- Linux represents accounts in
/etc/passwd. Password hashes are stored in/etc/shadow.
- Linux represents accounts in
- UIDs and GIDs
- Numeric user ID (UID) and primary group ID (GID) are recorded in
/etc/passwd.
- Numeric user ID (UID) and primary group ID (GID) are recorded in
- Home directories and default shells
- User home directories typically live at
/home/username. Login shell examples:/bin/bash.
- User home directories typically live at
adduservsuseraddadduseris interactive and prompts for details.useraddis more minimal/non-interactive but accepts flags for behavior.
- Password management
passwd usernameto set or change a user’s password.
- Modifying accounts
usermodcan change shell, rename users, and append supplemental groups.
- Groups and
/etc/group- Create groups, inspect membership, and assign privileges by group membership.
sudovssusudo(“super user do”) runs a single command with elevated privileges.suswitches user accounts (requires the target user’s password unless usingsudo).
- Sudoers and
visudo/etc/sudoersdefines who can usesudo. Edit withvisudoto avoid syntax errors.- Group-based sudo (e.g.,
%sudo) andNOPASSWDoptions are commonly used.
- Principle of least privilege
- Grant sudo rights only when necessary and remove privileges when finished.
Best practices: - Don’t routinely log in as root; prefer
sudo. - Usevisudoto edit the sudoers file to avoid breaking sudo with syntax errors. - Follow the principle of least privilege when granting access.
Commands and flags (quick reference)
whoami— show current usercat /etc/passwd— list users and account fieldssudo cat /etc/shadow— view hashed passwords (requires root)adduser username— interactive user creationuseradd username— non-interactive user creationuseradd -m username— create user and home directorypasswd username— set/change passwordusermod --shell /bin/bash username— change default shellusermod -l newname oldname— rename userusermod -aG groupname username— append user to supplemental groupsu - username— switch to another user (requires that user’s password)sudo su -— become root (uses your sudo privilege)sudo visudo(orsudo vi /etc/sudoers) — edit sudoers file safely (visudorecommended)sudo userdel username— delete usersudo groupadd groupname— create groupcat /etc/group— view groups and membershipssudo gpasswd -d username groupname— remove user from groupsudo groupdel groupname— delete a group
Tutorial / guide elements & resources
- Live demo available in a free Hack The Box Academy browser lab (Linux Fundamentals → User Management module).
- Step-by-step actions demonstrated:
- Create users (e.g., Thor, Iron Man), set passwords.
- Inspect
/etc/passwdand/etc/shadow. - Create groups and view
/etc/group. - Edit sudoers to grant sudo rights to a group.
- Add/remove users to/from groups.
- Delete users and groups.
- Advice reiterated throughout:
- Prefer
sudoover logging in as root. - Use
visudofor editing/etc/sudoers. - Remove elevated privileges when they are no longer needed.
- Prefer
- Additional materials:
- HTB Academy course page includes a command summary and a quiz.
- Video description links to a free quiz and the HTB Academy lab.
- HTB Academy offers a student subscription and some modules provide CPE credits.
Main speakers / sources
- Video presenter: host of the “Linux for Hackers” series, who demonstrates commands and concepts.
- Hack The Box Academy: sponsor and provider of the browser-based Linux lab and course materials.
Category
Technology
Share this summary
Is the summary off?
If you think the summary is inaccurate, you can reprocess it with the latest model.
Preparing reprocess...