So, you just spun up a Linux machine (maybe on a VM or in the cloud), and now you want to act like a sysadmin.
Oh just me? Well, I'm here to humble us both because there's a long road ahead...
Still, one of the first things you'll need to know is how to manage users like a pro.
Let's dive into some essential commands: useradd, passwd, su, and userdel.
Think of these commands as your User Control Panel ... but Super Powered, no need for that GUI stuff. 😎
📚 Table of Contents
- Create New Users (useradd)
- Set Passwords (passwd)
- Switch Users (su)
- Delete Users (userdel)
- Pro Tips
- Windows Comparison
- Wrapping Up
  
  
  🔧 useradd – Create New Users
useradd is like the “Create Account” option in Windows, but with style.
Basic Syntax:
sudo useradd [options] username
Common Options:
| Option | What it does | 
|---|---|
| -m | Create the user’s home directory | 
| -d /custom/home | Set a custom home directory | 
| -s /bin/bash | Set the user’s default shell | 
| -u UID | Assign a specific user ID | 
| -g groupname | Set the user’s primary group | 
| -G group1,group2 | Add the user to supplementary groups | 
| -e YYYY-MM-DD | Set account expiration date | 
| -c "Comment" | Add a user description | 
Example:
sudo useradd -m -s /bin/bash -c "Web Developer" alice
  
  
  🔐 passwd – Set or Change User Passwords
Syntax:
sudo passwd username
Example:
sudo passwd alice
  
  
  🔁 su – Switch User
Syntax:
su - username
Example:
su - alice
📝 Note: You can use sudo su - to become root, but tread carefully, with great power comes great responsibility... though let’s be real, Peter Parker probably isn't reading this, 🕷️ So maybe just steer clear unless you really know what you're doing!
  
  
  🧨 userdel – Delete Users
Syntax:
sudo userdel [options] username
Common Options:
| Option | What it does | 
|---|---|
| -r | Remove the user’s home directory and mail spool | 
Example:
sudo userdel -r alice
🧠 Pro Tips
- Want to see all user and system accounts?
  cat /etc/passwd
- Want to check details for a specific user?
  grep <username> /etc/passwd
- Want to see what groups a specific user belongs to?
  groups <username>
- Want to check group membership or definitions?
  cat /etc/group
- Or filter for a specific group:
  grep <groupname> /etc/group
- Need to modify an existing user (like changing their shell or adding them to groups)?
  sudo usermod [options] username
📝 Note: usermod is a powerful command with lots of options, enough to deserve its own article! From changing usernames to assigning new shells or managing group memberships, it’s a whole-nother rabbit hole. Stay tuned, maybe I'll cover that later.
🪟 Quick Windows Comparison
| Windows Action | Linux Command | 
|---|---|
| Add a new user (GUI) | useradd -m username | 
| Change password (Ctrl+Alt+Del) | passwd username | 
| Switch user (Start > Switch user) | su - username | 
| Delete user | userdel -r username | 
🏁 Wrapping Up
That’s your crash course on user management! Whether you're building out a secure dev server or managing a personal VM, these commands are must-know tools in your Linux toolkit.
Have fun managing users responsibly. 😄
💬 Let’s Connect
 

 
    
Top comments (0)