Linux Users, Groups, and Sudo Permissions¶
User and permission management is a core responsibility of DevOps engineers.
This section explains how Linux handles users, groups, file ownership, and sudo access, which are critical for server security and access control.
sudo – Getting Root Permissions¶
sudo allows a normal user to execute commands with root (administrator) privileges.
ll /etc/passwd
Trying to edit system files as a normal user:
vi /etc/passwd # Read-only, cannot write
Using sudo:
sudo vi /etc/passwd # Able to write
📌 DevOps Tip: Avoid logging in directly as root. Use sudo instead.
Understanding User and Group Permissions¶
Each file in Linux has: - Owner - Group - Permissions
Example:
[opc@new-k8s etc]$ ll /etc/os-release
-rw-r--r--. 1 root root 452 Sep 30 2020 /etc/os-release
Breakdown:
- root → owner
- root → group
- rw-r--r-- → permissions
Switching Users¶
sudo su
Switch to another user:
su vignesh
Switch with full environment:
su - vignesh
Creating a User¶
Ubuntu / Debian Based Systems¶
By default, useradd creates a user without a home directory.
useradd test
Create user with home directory:
useradd -m test1
Set Password for a User¶
passwd test
Verify User Creation¶
cat /etc/passwd
Test: User Installing a Package¶
sudo yum install tree
❌ This will fail because the user does not have sudo privileges.
Giving Sudo Permission to a User¶
To grant sudo access, add the user to the appropriate group.
CentOS / Oracle Linux / RHEL¶
usermod -aG wheel test
Group name: wheel
Ubuntu / Debian¶
usermod -aG sudo test
Group name: sudo
Verify Group Membership¶
id test
cat /etc/group
Test Again: Installing Package¶
sudo yum install tree
✅ This will now work because the user has sudo privileges.
Remove User from Group¶
gpasswd -d test wheel
Delete a User¶
Delete user without deleting files¶
userdel test
Delete user along with home directory¶
userdel -r test
Practice Tasks¶
- Create a new user named
devops - Set a password for the user
- Try editing
/etc/hostswithout sudo - Add the user to sudo group
- Verify sudo access
- Remove the user
🧠 Quick Quiz — Users & Sudo Permissions¶
Which group gives sudo access to users on Ubuntu systems?
📝 Want More Practice?¶
To strengthen your understanding and prepare for interviews, try the full 20-question practice quiz based on this chapter:
👉 Start Users & Sudo Permissions Quiz (20 Questions)
📬 DevopsPilot Weekly — Learn DevOps, Cloud & Gen AI the simple way.
👉 Subscribe here