Chapter 12: User and Permission Management in WSL Ubuntu - Tutorial Rays
Linux

Chapter 12: User and Permission Management in WSL Ubuntu

Chapter 12: User and Permission Management in WSL Ubuntu

Managing users and file permissions is essential for system security and proper access control in Linux. WSL Ubuntu allows you to create users, assign groups, and control file permissions easily.

In this chapter, you’ll learn how to create users, manage groups, and control file permissions using essential Linux commands.

👤 Managing Users

📌 Create a New User

sudo adduser username

Example:

sudo adduser umar

This will prompt for password and optional details.

📌 Delete a User

sudo deluser username

To remove home directory as well:

sudo deluser --remove-home username

📌 Modify a User

sudo usermod -aG groupname username

Adds a user to a group (append -aG to avoid removing from other groups).

👥 Managing Groups

📌 Create a Group

sudo addgroup groupname

📌 Delete a Group

sudo delgroup groupname

📌 View Groups for a User

groups username

🔑 File Permissions

📌 View Permissions

ls -l filename

Example output:

-rw-r--r-- 1 umar users 1024 Aug 21 10:00 file.txt
  • Owner: umar
  • Group: users
  • Permissions: rw-r--r-- (read/write for owner, read for group and others)

📌 Change File Ownership

sudo chown user:group filename

Example:

sudo chown umar:users file.txt

📌 Change File Permissions

chmod 755 script.sh
  • 7 → read/write/execute (owner)
  • 5 → read/execute (group)
  • 5 → read/execute (others)

🧪 Practice Exercises

# Create a user
sudo adduser john

# Add user to a group
sudo usermod -aG sudo john

# View groups for a user
groups john

# Change file ownership
sudo chown john:users file.txt

# Change file permissions
chmod 644 file.txt
chmod 755 script.sh

✅ Summary

  • Use adduser / deluser to create or delete users
  • Use addgroup / delgroup to manage groups
  • Use usermod -aG to add users to groups
  • Use ls -l to view file permissions
  • Use chmod to change permissions and chown to change ownership
  • Proper user and permission management ensures system security

▶️ Coming Up Next

Chapter 13 – Scheduled Tasks and Cron Jobs in WSL Ubuntu
Learn how to automate tasks using cron and schedule scripts to run at specific intervals.

Leave a Reply

Your email address will not be published. Required fields are marked *