# Linux Special Permissions: SUID, SGID, and Sticky Bit Explained

Listen to this Post

Linux uses special permissions like SUID, SGID, and the Sticky Bit for advanced access control. These permissions provide additional security and functionality beyond standard read, write, and execute permissions.

SUID (Set User ID)

  • When set on an executable file, it runs with the file owner’s privileges, not the user executing it.
  • Example: `/usr/bin/passwd` (allows users to change their password by temporarily gaining root access).

Command to set SUID:

chmod u+s filename 

**Check SUID permission:**

ls -l /usr/bin/passwd 

Output:

-rwsr-xr-x 1 root root 59976 Nov 24 2022 /usr/bin/passwd 

## **SGID (Set Group ID)**

  • When set on a directory, new files inherit the directory’s group ownership.
  • When set on an executable, it runs with the group owner’s privileges.

**Command to set SGID:**

chmod g+s directoryname 

**Check SGID permission:**

ls -ld /var/www 

## **Sticky Bit**

  • Used on shared directories (e.g., /tmp) to restrict file deletion to only the file owner, directory owner, or root.

**Command to set Sticky Bit:**

chmod +t /shared_directory 

**Verify Sticky Bit:**

ls -ld /tmp 

Output:

drwxrwxrwt 10 root root 4096 Mar 28 10:00 /tmp 

# **You Should Know:**

### **1. Finding Files with SUID/SGID Permissions**

Use `find` to locate potentially risky files:

find / -perm -4000 -type f 2>/dev/null # SUID 
find / -perm -2000 -type f 2>/dev/null # SGID 

### **2. Removing SUID/SGID Permissions**

chmod u-s /path/to/file # Remove SUID 
chmod g-s /path/to/file # Remove SGID 

### **3. Secure Shared Directories**

Prevent unauthorized deletions in shared folders:

chmod 1777 /shared_folder 

### **4. Numerical Permissions for Special Bits**

  • SUID: `4000`
  • SGID: `2000`
  • Sticky Bit: `1000`

Example:

chmod 4755 script.sh # SUID + rwxr-xr-x 

### **5. Checking Permissions in Octal Format**

stat -c "%a %n" /usr/bin/passwd 

# **What Undercode Say:**

Special permissions (SUID, SGID, Sticky Bit) enhance Linux security but can be misused if improperly configured. Always audit SUID/SGID files and restrict Sticky Bit usage to necessary directories. Use `find` and `chmod` to manage these permissions effectively.

# **Expected Output:**

-rwsr-xr-x 1 root root 59976 Nov 24 2022 /usr/bin/passwd 
drwxrwxrwt 10 root root 4096 Mar 28 10:00 /tmp 

**Reference:**

Linux Special Permissions Guide

References:

Reported By: Xmodulo Linux – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image