Linux Commands

🐧 Linux Server Administration: Working with Users, Groups & Permissions – TYBSc IT Practical Guide

Are you a TYBSc IT student learning Linux Server Administration? One of the core practicals you’ll encounter is about managing users, groups, and permissions in Linux. This blog will guide you through the practical tasks step by step with commands and explanations. Ideal for TYBSc IT Sem 5 students, beginners in Linux, or anyone preparing for Linux sysadmin interviews.

A) Creating and Managing Users

1. Add New User

sudo adduser john
Adding user `john' ...
Adding new group `john' (1001) ...
Adding new user `john' (1001) with group `john' ...
Creating home directory `/home/john' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
    

2. Rename User

sudo usermod -l johnny john
(If successful, there will be no output.)
    

3. Delete User

sudo deluser johnny
Removing user `johnny' ...
Warning: group `johnny' has no more members.
Done.
    

4. Delete User with Home

sudo deluser --remove-home johnny
Removing user `johnny' ...
Removing home directory `/home/johnny' ...
Done.
    
B) Creating and Managing Groups

1. Create Group

sudo groupadd developers
(No output if successful.)
    

2. Add User to Group

sudo useradd -m anita
sudo usermod -aG developers anita
(Commands execute silently if successful.)
    

3. View User Groups

groups anita
anita : anita developers
    

4. Delete Group

sudo groupdel developers
(No output if successful.)
    
C) File Permissions & Advanced Permissions

1. Check Permissions

ls -l test.txt
-rw-r--r-- 1 john john 0 Jun 1 09:30 test.txt
    

2. Change Permissions

chmod 755 test.sh
(No output if successful.)
    

3. Change Ownership

sudo chown root:root test.txt
(No output if successful.)
    

🔐 Sticky Bit (shared dir)

sudo mkdir /shared
sudo chmod +t /shared
ls -ld /shared
drwxrwxrwt 2 root root 4096 Jun 1 09:32 /shared
    

🔐 SUID (execute as owner)

sudo chmod u+s test.sh
ls -l test.sh
-rwsr-xr-x 1 root root 1234 Jun 1 09:35 test.sh
    

🔐 SGID (execute as group)

sudo chmod g+s test.sh
ls -l test.sh
-rwsr-sr-x 1 root root 1234 Jun 1 09:36 test.sh
    

✅ This practical covers:

  • ✅ Creating and managing users using adduser, usermod, deluser
  • ✅ Creating and managing groups using groupadd, usermod, groupdel
  • ✅ Assigning file and directory permissions using chmod, chown, and special permissions: SUID, SGID, and sticky bit