0% found this document useful (0 votes)
34 views10 pages

User & Group Management Tutorial

This document is a hands-on tutorial for user and group management in Linux, covering topics such as user creation, group management, access management, file permissions, root privileges, and file management. It includes practical exercises and a time breakdown for each section, along with key commands and a cheat sheet for quick reference. Prerequisites include having an Ubuntu system and basic shell command knowledge.

Uploaded by

Rik Koki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views10 pages

User & Group Management Tutorial

This document is a hands-on tutorial for user and group management in Linux, covering topics such as user creation, group management, access management, file permissions, root privileges, and file management. It includes practical exercises and a time breakdown for each section, along with key commands and a cheat sheet for quick reference. Prerequisites include having an Ubuntu system and basic shell command knowledge.

Uploaded by

Rik Koki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

🐧 User & Group Management

Hands-On Linux Practice Tutorial


Topics Covered:
1. User Management
2. Group Management
3. Access Management
4. File Permissions
5. Root Privileges
6. File Management

🧭 Prerequisites:
 Ubuntu system (or any Debian-based Linux)
 Access to terminal
 Basic understanding of shell commands

📚 Time Breakdown
Section Topic Time
1 Intro + User Management 15 min
2 Group Management 15 min
3 Access and File Permissions 20 min
4 Root Privileges and sudo 15 min
5 File and Directory Management 20 min
6 Wrap-up Challenge 5 min

1. User Management (15 minutes)


🔹 Check current user:

whoami
🔹 List system users:

cut -d: -f1 /etc/passwd

🔹 Create a new user:

sudo adduser alice

🔹 Switch to the user:

su - alice

Press Ctrl+D or type exit to return.

🔹 Delete a user:

sudo deluser alice

📘 Chapter 5 — "Managing Users and Groups"

✅ Exercise 1:

 Create a user named testuser


 Set a password for the user
 Switch to the user and confirm you’re logged in as testuser

👥 2. Group Management (15 minutes)


🔹 View current groups:

groups
🔹 Create a group:

sudo addgroup developers

🔹 Add user to a group:

sudo usermod -aG developers testuser

🔹 Verify group membership:

groups testuser

🔹 Remove user from a group:

sudo gpasswd -d testuser developers

📘 Chapter 5 — "Managing Users and Groups"

✅ Exercise 2:

 Create a group called students


 Add testuser to the group
 Verify using the groups command

🔐 3. Access Management & File Permissions


(20 minutes)
🔹 Check permissions:

ls -l

Example output:
-rw-r--r-- 1 alice alice 4096 Apr 30 12:00 file.txt

Breakdown of permissions:

[owner][group][others]
rw- r-- r--

🔹 Change file permissions:

chmod u+x script.sh # Add execute for owner


chmod g-w file.txt # Remove write from group
chmod o+r file.txt # Add read for others

🔹 Numeric permissions:

chmod 755 script.sh # rwxr-xr-x


chmod 644 file.txt # rw-r--r--

🔹 Change ownership:

sudo chown testuser file.txt


sudo chown testuser:developers file.txt

📘 Chapter 6 — "File System Permissions and Ownership"

✅ Exercise 3:

 Create a file called hello.txt


 Change its permissions so only the owner can read/write
 Make sure others can’t access it
: 4. Root Privileges and sudo (15 minutes)
🔹 Check if you’re root:

whoami

🔹 Use sudo to run admin commands:

sudo apt update

🔹 Run a shell as root:

sudo -i

🔹 Add a user to the sudo group:

sudo usermod -aG sudo testuser

📘 Chapter 8 — “Root and Sudo”

✅ Exercise 4:

 Try running apt update as a normal user


 Add yourself to the sudo group (if needed)
 Run the command again using sudo

📁 5. File and Directory Management (20


minutes)
🔹 Create files and directories:

mkdir myfolder
touch myfolder/notes.txt
🔹 Move and rename files:

mv myfolder/notes.txt myfolder/tasks.txt

🔹 Copy files:

cp myfolder/tasks.txt myfolder/tasks_backup.txt

🔹 Delete files and directories:

rm myfolder/tasks_backup.txt
rm -r myfolder

🔹 View contents:

ls -l myfolder/
cat myfolder/tasks.txt

📘 Chapter 4 — “Working with Files and Directories”

✅ Exercise 5:

 Create a directory project


 Inside it, create a file readme.txt
 Write your name into the file using echo
 Rename the file to intro.txt
 Delete the file and directory

🚀 6. Wrap-Up Challenge (5 minutes)


Combine everything you’ve learned in a mini project:

✅ Challenge:

1. Create a user projectuser


2. Create a group projectteam and add projectuser to it
3. As root, create a folder /opt/project, assign ownership to
projectuser:projectteam
4. Set permissions so only the group can write to it, others can only
read
5. Switch to projectuser and create a file inside /opt/project

🧠 Summary Table
Topic Key Command
Create user sudo adduser username
Delete user sudo deluser username
Create group sudo addgroup groupname
sudo usermod -aG groupname
Add user to group
username
View permissions ls -l
Change permissions chmod, chown
File operations cp, mv, rm, touch, mkdir
Root access sudo, sudo -i
🧾 Linux User & Access
Management Cheat Sheet

👤 User Management
Action Command
Create user sudo adduser <username>
Delete user sudo deluser <username>
Switch user su - <username>
View all users cut -d: -f1 /etc/passwd
Set/change password sudo passwd <username>

👥 Group Management
Action Command
Create group sudo addgroup <groupname>
Delete group sudo delgroup <groupname>
sudo usermod -aG <groupname>
Add user to group
<username>
Remove user from sudo gpasswd -d <username>
group <groupname>
List groups for user groups <username>

🔐 File Permissions
Action Command
View permissions ls -l
Change permissions (symbolic) chmod u+x <file>
Change permissions (numeric) chmod 755 <file>
sudo chown
Change ownership
<user>:<group> <file>

Permission Breakdown (e.g. -rwxr-xr--):


 u = user (owner)
 g = group
 o = others
 r = read, w = write, x = execute

Numeric Equivalents:

Permission Number
r (read) 4
w (write) 2
x (execute) 1
rw- 6
r-x 5
rwx 7

: Root & sudo


Action Command
Run as root sudo <command>
Become root sudo -i
Add user to sudo usermod -aG sudo
sudoers <username>

📁 File & Directory Management


Action Command
Create directory mkdir <dir>
Create file touch <file>
Copy file cp <source> <dest>
Move/rename file mv <source> <dest>
Delete file rm <file>
Delete directory rm -r <dir>
View file contents cat <file>

🧪 Bonus Commands
Purpose Command
Show current user whoami
Display current directory pwd
Search text in file grep "<text>" <file>
List all users in group getent group <groupname>

You might also like