Table Of Content
Introduction
Have you ever wondered how Linux ensures users can collaborate without stepping on each other's toes or how a regular user can run powerful programs without being given the keys to the whole system?
That's where special permissions come in. These are not your everyday read, write, and execute. These are the VIP badges: SUID, SGID, and the Sticky Bit.
Quick Recap: Standard vs Special Permissions
here’s the usual setup:
r (read): View contents
w (write): Modify contents
x (execute): Run files or access directories
But sometimes, that's not enough...
That's why we have these special permissions that are important in multiuser environments and shared directories.
- SUID (Set User ID)
- SGID (Set Group ID)
- Sticky Bit
1. SUID (Borrowing the Boss's Authority)
SUID (Set User ID) allows users to run a program as if they were the file owner. Commonly, the owner is root.
Real-Life Analogy:
Imagine a guest in a hotel needs to access a restricted floor. Instead of giving them a master key (root access), the elevator (program) temporarily acts as if they are the manager (file owner) just to get them there and only there.
Example:
Check the file's permissions before:
$ ls -l script.sh
-rwxr-xr-x 1 root users 123 May 8 2025 script.sh
- The owner is root, and the script is executable (x).
Run the command:
chmod u+s script.sh
- Check permissions after:
$ ls -l script.sh
-rwsr-xr-x 1 root users 123 May 8 2025 script.sh
The s in rws indicates the setuid bit is set.
2. SGID (Group Consistency Keeper)
Set Group ID
Purpose
- On files: Runs the file with the group ID of the file's group owner.
- On directories: Ensures new files/folders inherit the directory's group ownership.
Real-Life Analogy:
You and your coworkers share a project folder. SGID makes sure everything dropped in stays under the same project group, so collaboration is smooth and consistent.
mkdir /shared
chgrp developers /shared
chmod g+s /shared
Now anything placed in /shared stays in the developers group.
Set It:
chmod g+s /some/dir
Tip: SGID is your friend when working in /var/www, /projects, or shared Git workspaces.
Listing:
drwxr-sr-x 2 www-data www-data 4096 May 8 10:30 html
3. Sticky Bit (Don't Touch My Stuff!)
Purpose:
Restricts file deletion in a directory so only the file’s owner (or root) can delete or rename files, even if others have write permission.
Real-Life Analogy:
Think of a public bulletin board. Everyone can post notes, but only the original author can take theirs down. That’s the sticky bit.
Set Sticky Bit:
ls -ld /tmp
Output:
drwxrwxrwt 10 root root 4096 May 8 10:30 /tmp
See the t at the end? That’s the sticky bit.
🔧 Set It:
chmod +t /shared-folder
💡 Use this anywhere multiple users need to share space, but still need file safety.
Set Sticky Bit:
chmod +t directory
Example:
drwxrwxrwt 10 root root 4096 May 8 10:30 /tmp
Numeric Representation of Special Permissions
Use octal numbers to combine special permissions with standard ones:
- SUID = 4
- SGID = 2
- Sticky Bit = 1
Examples:
chmod 4755 myscript.sh # Sets SUID
chmod 2755 shared_folder # Sets SGID
chmod 1777 /tmp # Sets Sticky Bit
Security Importance of Special Permissions
Special permissions help enforce secure system behavior while allowing necessary flexibility:
SUID allows limited privilege escalation. It ensures that users can run specific programs with higher privileges without granting them full root access. However, misconfigured SUID programs are a common target for attackers to gain unauthorized root access.
SGID ensures group consistency, especially in shared development or collaboration directories. It helps prevent users from accidentally assigning wrong group ownership, which could leak sensitive data or cause privilege issues.
Sticky Bit protects shared directories by preventing users from deleting or renaming each other’s files, which is crucial in directories like
/tmp
.
Best Practices:
# Audit SUID and SGID files
find / -perm /6000 -type f 2>/dev/null
# Audit Sticky Bit directories
find / -perm /1000 -type d 2>/dev/null
- Avoid setting SUID/SGID on scripts, as they are more easily exploited than compiled binaries.
- Use special permissions only when necessary and monitor for unauthorized changes.
Conclusion
Special permissions in Linux SUID, SGID, and Sticky Bit are powerful tools for controlling access and behavior in a multi-user environment. They support secure delegation of privileges and controlled collaboration, but they must be used carefully. Misuse or misconfiguration can lead to serious security vulnerabilities. Always apply the principle of least privilege and audit permissions regularly to maintain a secure system.
I would love to hear your thoughts, experiences, or tips about Linux!
Feel free to share in the comments and join the conversation.
Connect with me on LinkedIn !
#30DaysLinuxChallenge #CloudWhistler #RedHat #Cloudsecurity #DevOps #Linux #OpenSource #CloudComputing #RedHatEnterpriseLinux #SystemLogs #EnterpriseIT #Observability #Logging #SysAdmin #Automation #CloudEngineer #TechForBusiness #ITSupport #SRE #CloudOps