CLI:Basics – User Management in Linux
Welcome back to the CLI:Basics series! In this post, we’ll cover essential user management commands for Linux. Even if you’re the only user on your system, it’s important to understand how user accounts and groups work—because on Linux, you are the system administrator.
Whether you’re managing one account or one million (okay, probably not literally), these concepts scale the same.
We’ll walk through:
- Checking your user and group info
- Adding and removing users
- Assigning users to groups
- Setting user passwords
Let’s get started.
👤 id
– Display User and Group Info
id
This shows:
- Your user ID (UID)
- Your group ID (GID)
- A list of groups you belong to
Example output:
uid=1000(ltl) gid=1000(ltl) groups=1000(ltl),4(adm),27(sudo),...
- UIDs below 1000 are typically system accounts.
- UIDs 1000+ are normal user accounts (you, your roommate, etc).
❓ whoami
– Who Am I Really?
whoami
This command returns the current effective user, which is especially helpful after using sudo
:
sudo -i
whoami
Output:
root
Even though you’re logged in as yourself, you’re now operating as root.
👥 groups
– Show Group Membership
groups
Lists all groups your current user belongs to. This includes standard groups like users
, sudo
, lpadmin
, etc. Being in sudo
allows you to run commands with elevated privileges.
➕ useradd
– Create a New User
sudo useradd -m scott
The -m
flag ensures the user’s home directory is created at /home/scott
. Without sudo
, this command will fail due to insufficient permissions.
🔑 passwd
– Set a User’s Password
sudo passwd scott
After creating a user, use this to assign them a login password.
➖ userdel
– Remove a User Account
sudo userdel scott
This removes the system-level account and login access, but does not delete their home directory by default. That means /home/scott
will remain, which is useful if you need to access their files later.
🛠️ usermod
– Modify User Groups
sudo usermod -aG sudo scott
This command:
-aG
appends the user to one or more groups (in this case,sudo
)- Gives Scott permission to run commands as root using
sudo
⚠️ Be careful not to overwrite existing group memberships when using
usermod
without-a
.
Notes on Teaching Order
You may notice some “out of order” teaching in these videos—and that’s intentional. Many commands build on each other, and it’s hard to introduce one without touching another. The goal is to keep things realistic and practical, not just academically tidy.
Summary of Commands Covered
Command | Description |
---|---|
id | Show user ID, group ID, and memberships |
whoami | Show current effective user |
groups | Show current user’s group memberships |
useradd -m | Add a new user with a home directory |
passwd | Set or update a user’s password |
userdel | Remove a user account |
usermod -aG | Add a user to a group |
Final Thoughts
User management is a fundamental skill for any Linux user—even if you’re the only person using the system. As we move further into this series, we’ll begin touching on multi-user environments, permissions, and access control.
Be sure to subscribe on YouTube and click the bell so you don’t miss the next video in the CLI:Basics series!