Managing Users and Groups
Learn to create, modify, and delete user accounts and groups, assign sudo privileges, and understand user IDs and group IDs.
Managing Users and Groups is a free Linux Server Deployment & SSH Mastery lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Server Deployment & SSH Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Users & Groups: Access Control Basics
Welcome to managing users and groups on Linux! This lesson is crucial for server administration, security, and organizing who can do what.
Every action on a Linux server is performed by a user. Users are organized into groups to simplify permissions and access control.
Your Digital Identity: User Accounts
A user account is your digital identity on a Linux system. It defines your home directory, shell, and what files and commands you can access.
- Each user has a unique username.
- Users log in with a password (or SSH key).
- Accounts isolate user activities, enhancing security.
Creating New Users with `useradd`
The primary command to create a new user account is useradd. By default, it creates a new user, a home directory, and assigns a default shell.
You'll need sudo (superuser do) privileges to run this command, as it modifies system settings.
sudo useradd newuserSetting User Passwords with `passwd`
After creating a user, they won't be able to log in until you set a password for them. The passwd command is used for this.
You'll be prompted to enter the new password twice. Remember to choose strong, unique passwords!
sudo passwd newuserUnique Identifiers: User IDs (UIDs)
Behind every username, Linux uses a unique number called a User ID (UID). This is how the system truly identifies users.
- UID 0 is always for the root user.
- UIDs 1-999 are typically reserved for system accounts.
- Regular user accounts usually start from UID 1000.
You can see a user's UID with the id command.
id newuserModifying User Details with `usermod`
Need to change a user's home directory, login shell, or username? The usermod command is your tool.
-d: Change home directory.-s: Change login shell.-l: Change username.
Always use sudo with usermod.
sudo usermod -s /bin/bash newuserDeleting Users with `userdel`
When a user no longer needs access, you can remove their account using userdel. It's important to decide if you want to keep or remove their home directory.
userdel username: Deletes the user account, but keeps their home directory and mail spool.userdel -r username: Deletes the user account and removes their home directory and mail spool.
sudo userdel -r olduserOrganizing Users with Groups
Groups allow you to manage permissions for multiple users at once. Instead of setting permissions for each individual, you set them for a group, and then add users to that group.
- Every user belongs to at least one primary group.
- Users can also belong to multiple supplementary groups.
Managing Groups: `groupadd`, `groupdel`, `gpasswd`
Just like users, groups have commands for creation, deletion, and management:
groupadd groupname: Creates a new group.groupdel groupname: Deletes an existing group.gpasswd -a user group: Adds a user to a supplementary group.gpasswd -d user group: Removes a user from a group.
sudo groupadd developers
sudo gpasswd -a newuser developersGranting Admin Power: Sudo Privileges
The sudo command allows regular users to execute commands with root (administrator) privileges. This is safer than logging in as root directly.
To grant a user sudo access, you typically add them to a special group, often named sudo (on Debian/Ubuntu) or wheel (on Red Hat/CentOS).
sudo usermod -aG sudo newuserQuick Check: User & Group Commands
Which command would you use to remove a user named olduser AND delete their home directory?
Recap: Users, Groups & Control
Great job! You've learned the essentials of managing users and groups on a Linux server:
- Use
useraddandpasswdto create new users. usermodhelps modify user properties.userdelremoves user accounts.groupadd,groupdel, andgpasswdmanage groups.- Grant
sudoprivileges by adding users to the appropriate group.
Understanding these commands is fundamental for secure and organized server administration.
Frequently asked questions
Is the “Managing Users and Groups” lesson free?
Yes — the full text of “Managing Users and Groups” is free to read here on the web, and the Linux Server Deployment & SSH Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Server Deployment & SSH Mastery course, upgrade to CoddyKit PRO.
What will I learn in “Managing Users and Groups”?
Learn to create, modify, and delete user accounts and groups, assign sudo privileges, and understand user IDs and group IDs. You practise Linux Server Deployment & SSH Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Linux Server Deployment & SSH Mastery?
No prior experience is required. Linux Server Deployment & SSH Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Managing Users and Groups” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Linux Server Deployment & SSH Mastery lesson?
Yes. Every Linux Server Deployment & SSH Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Managing Users and Groups
- Monitoring System Processes
- Scheduled Tasks with Cron
- Managing System Services with systemd