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 noobninja
It 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 password
Now, "noobninja" is part of your Linux dojo. 🎉
Switching Users – Be Like a Chameleon
Want to become another user? Use:
su - noobninja
This logs you in as noobninja. Want to go back? Just type:
exit
Boom! 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 noobninja
Now, "noobninja" can use sudo
to execute commands as root.
Deleting Users – Banishment!
To remove a user:
sudo deluser noobninja
To delete a user and their home directory (wipe them from existence):
sudo deluser --remove-home noobninja
Be careful! There's no undo button.
Checking Users on the System
Want to see all users?
cat /etc/passwd
Too much info? Just filter usernames:
cut -d: -f1 /etc/passwd
To see who’s currently logged in:
who
Or for a detailed view:
w
Locking & Unlocking Users
Sometimes, you need to lock a user out (like when your little brother messes with your system):
sudo passwd -l noobninja
To unlock them later:
sudo passwd -u noobninja
Your 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 - hacker
If everything works, congrats! You’ve mastered the Way of the Root! 🥋🐧
Up next: The Art of File Permissions! 🔥🔒