User Management – The Way of the Root
Welcome, warrior! Every Linux system has multiple users, but only one holds ultimate power—the root user. Root can do anything… but with great power comes great responsibility (and a high chance of breaking things).
Today, we learn to create, manage, and delete users like a true Linux master.
Who Am I? (Identity Crisis)
Before we start, let’s confirm who we are:
whoami # Am I a normal user or the all-powerful root?If you see root, be careful! You wield dangerous power. ⚠️ If not, you can become root with:
sudo su -Now, let’s manage some users!
Creating New Users – Welcome to the Dojo
To add a new warrior (user) to the system, use:
sudo adduser noobninjaIt will ask for a password (set something secret).
Want to skip the prompts?
sudo useradd -m -s /bin/bash noobninja
sudo passwd noobninja # Set a passwordNow, "noobninja" is part of your Linux dojo. 🎉
Switching Users – Be Like a Chameleon
Want to become another user? Use:
su - noobninjaThis logs you in as noobninja. Want to go back? Just type:
exitBoom! You're back to your original self.
Giving a User Superpowers (Sudo Access)
By default, normal users are mere mortals. To grant them sudo powers (admin rights), add them to the sudo group:
sudo usermod -aG sudo noobninjaNow, "noobninja" can use sudo to execute commands as root.
Deleting Users – Banishment!
To remove a user:
sudo deluser noobninjaTo delete a user and their home directory (wipe them from existence):
sudo deluser --remove-home noobninjaBe careful! There's no undo button.
Checking Users on the System
Want to see all users?
cat /etc/passwdToo much info? Just filter usernames:
cut -d: -f1 /etc/passwdTo see who’s currently logged in:
whoOr for a detailed view:
wLocking & Unlocking Users
Sometimes, you need to lock a user out (like when your little brother messes with your system):
sudo passwd -l noobninjaTo unlock them later:
sudo passwd -u noobninjaYour Training Task
Try creating a new user, switching to them, and giving them sudo powers. Then, delete them (if you dare).
sudo adduser hacker
sudo usermod -aG sudo hacker
su - hackerIf everything works, congrats! You’ve mastered the Way of the Root! 🥋🐧
Up next: The Art of File Permissions! 🔥🔒
