
When it’s time to troubleshoot Linux file permissions, start by asking which operation failed. Running program, editing file, and deleting same file involve different permissions to check. That distinction matter when “ls -l” shows an “s” or a “t” where I expected an “x”.
In this guide, I will walk you through permissions commonly used on “/tmp”. If you manage Linux VPS or share deployment directory with teammate, these example will help you read mode, choose right setting, and verify what changed.
TL;DR
- Linux file permissions control user access to files and directories
- When program with SUID bit set run, it executes under privileges of file’s owner rather than user who launched it
- SGID enable group-based execution and directory group inheritance
- Sticky Bit prevent user from deleting or renaming other users’ files in shared directories
- Use “chmod 4755”, “chmod 2775”, and “chmod 1777” to set special permission
- Use “ls -l” and “ls -ld” to check file and directory permissions
- Regularly audit special permissions to maintain Linux security
How to Read Linux File Permission before Changing
Owner, group, and other
Use “ls -l” to inspect file and “ls -ld” to inspect directory itself. The “-d” matter if want directory’s mode and ownership on one line. Looking at “-rwxr-xr-x”, leading dash indicates that item is standard file rather than directory or special file.
Each ordinary permission has value: read is 4, write is 2, and execute is 1. Add those values within each group of three. That’s how “rwxr-xr-x” becomes 755. Add leading 4 for SUID and mode becomes 4755. Owner’s execute position then displays as “s”, giving “-rwsr-xr-x”.
Linux stores these permission flags as part of an inode’s mode information. Same special bits can behave differently depending on file type, which is why executable files and directories need to be examined separately. Linux inode manual explains these distinctions in detail.
If you are new to Linux permissions, start with our guide on Linux file permissions, including read, write, and execute access to understand the basics before exploring special permission bits.
Why directory permissions change diagnosis
On regular file, read let see content, write let modify them, and execute let run file if it’s executable in format Linux understand. On directory, read let list entry name, write support creating or removing entries, and execute let traverse directory and access entries by name. Creating, deleting, or renaming entry normally require both write and execute permission on relevant parent directory.
Read-only file can still be deletable if parent directory grant necessary access. When someone can edit file but can’t rename it, I check parent directory before touching file’s mode.
SUID on Linux
SUID stand for set user ID. Real user ID identify user account that started program. If Linux execute file with SUID permission enable, it temporarily use file owner’s permissions instead of user’s permission.
How SUID Work?
Consider executable file owned by root user. Normally, when regular user executes any program, it run with that user’s effective privileges. However, when SUID permission is enabled, program runs with effective user ID of its owner, provided operating system with permission.
For example, Linux “passwd” command commonly use SUID. Regular user need to change their passwords, but password-related account information is protected by operating system.
The SUID allows password utility to perform required privileged operations without giving ordinary users unrestricted root access. You can explore the execve system call manual for more technical details about executing programs and credential changes.
Check SUID Permissions
Use following command:
ls -l /usr/bin/passwdOn many Linux distributions, output resembles:
-rwsr-xr-x 1 root root 68248 /usr/bin/passwdNotice lowercase “s” in the owner’s execute position. This indicates SUID bit is enabled and owner execute permission is also present.
Set SUID Permission
Enable SUID using symbolic method as below:
chmod u+s filenameAlternatively, use numeric method as mentioned:
chmod 4755 filenameHere:
- 4 enables SUID
- 7 grants full read, write, and execute access to file owner
- 5 gives group read and execute permissions
- 5 gives others read and execute permissions
Remove SUID Permission
To remove SUID, execute:
chmod u-s filenameYou can verify result using:
ls -l filenameImportant SUID Security Consideration
SUID permissions should be assigned carefully, especially to root-owned executables. An incorrectly designed or vulnerable SUID program may allow unintended privilege escalation.
System administrators should regularly review SUID-enabled files and remove unnecessary permissions.
SGID in Linux
SGID stands for set group ID. On eligible executable, it set process’s effective group ID to file’s group when program start. Display follows same pattern as SUID. In group execute position, “s” means both bits are set, while “S” mean SGID is present and group execute is absent.
How SGID Work on Files?
When executable file has SGID enabled, program runs with effective group ID associated with file, subject to operating system and filesystem restrictions.
This allows programs to access resources associated with particular group without requiring every user to belong to that group directly.
How SGID Work on Directories?
SGID is particularly useful when multiple users work on shared project directories. To understand how Linux users and groups are organized, check out guide on listing users and groups in Ubuntu using command line.
All users in team need to create and modify files inside shared project directory. Without SGID, newly created files generally inherit creating user’s default group, which can create collaboration problems. By enabling SGID on shared directory, newly created files and subdirectories normally inherit directory’s group. This helps maintain consistent group ownership.
Set SGID Permission
Use following command:
chmod g+s shared_directoryAlternatively, use numeric permissions:
chmod 2775 shared_directoryHere:
- 2 enables SGID
- 7 gives owner full permissions
- 7 gives group full permissions
- 5 gives others read and execute permissions
Remove SGID Permission
Use below command:
chmod g-s shared_directoryThis removes SGID permission.
Note: SGID helps maintain group ownership, but it does not automatically give every group member write access. You must configure directory’s ordinary permissions appropriately.
For Example: Creating Shared Directory
First, to create directory:
mkdir projectAssign directory to group:
chgrp developers projectEnable SGID using below command:
chmod 2775 projectCheck permissions:
ls -ld projectOutput example:
drwxrwsr-x 2 root developers 4096 Nov 20 10:30 projectHere, check the lowercase “s” in the group’s execute position indicates that SGID is enabled. Files and subdirectories created inside this directory normally inherit the developers group.
Sticky bit in Linux
Sticky Bit is special Linux permission mainly used on shared directories. It prevent ordinary users from deleting or renaming files owned by other users inside directory, even when directory is writable by everyone.
This is especially useful for directories where multiple users need to create files.
How Sticky Bit Work
Consider the “/tmp” directory in Linux. It is commonly used to store temporary files created by different users and applications.
Multiple users need permission to create files inside it. However, without additional restrictions, user with write permission on directory could delete or rename another user’s files.
The Sticky Bit helps prevent this behavior. When enabled, users can generally remove or rename files in directory only if they:
- Own file
- Own directory
- Have necessary administrative privileges
Check Sticky Bit Permissions
Run below command:
ls -ld /tmpExample output:
drwxrwxrwt 12 root root 4096 Nov 20 10:30 /tmpNotice lowercase “t” at end of permission string. This indicates that Sticky Bit is enabled and directory also has execute permission for others.
Set Sticky Bit
Use symbolic method as mentioned:
chmod +t directory_nameAlternatively, use numeric permissions:
chmod 1777 directory_nameHere:
- 1 enables Sticky Bit
- 7 gives owner full permissions
- 7 gives group full permissions
- 7 gives others full permissions
Remove Sticky Bit
Use mentioned command:
chmod -t directory_nameThis disables Sticky Bit.
For example: Creating Shared Temporary Directory
Create directory using below command:
mkdir shared_tmpSet permissions:
chmod 1777 shared_tmpCheck permissions:
ls -ld shared_tmpExample output:
drwxrwxrwt 2 user user 4096 Nov 20 10:30 shared_tmpThe “t” at end confirms that Sticky Bit is enabled. Users can create files inside this directory, but ordinary users cannot delete or rename files owned by other users.
Difference Between SUID, SGID, Sticky Bit
Although all are special Linux permission, they perform different function. Here is quick comparison:
| Feature | SUID | SGID | Sticky Bit |
| Full form | Set User ID | Set Group ID | Sticky Bit |
| Numeric value | 4 | 2 | 1 |
| Main purpose | Uses file owner’s effective UID during execution | Uses file group’s effective GID during execution | Restricts file deletion in shared directories |
| File behavior | Changes effective user ID | Changes effective group ID | Has historical behavior on some systems |
| Directory behavior | Limited, system-dependent | Supports group inheritance | Restricts deletion and renaming |
| Symbolic representation | s | s | t |
| Common example | passwd | Shared project directory | /tmp |
Main difference is that SUID control effective user identity, SGID control effective group identity and directory group inheritance, while Sticky Bit control deletion and renaming behavior in shared directories.
Understanding Special Permission Numeric Values
Linux use four-digit octal format to represent special permissions along with standard permission.
The first digit represent special permission bits:
| Numeric Value | Special Permission |
| 4 | SUID |
| 2 | SGID |
| 1 | Sticky Bit |
| 0 | No special permission |
For example:
- 4755: SUID
chmod 4755 file- 2755: SGID
chmod 2755 directory- 1777: Sticky Bit
chmod 1777 directoryYou can also combine special permission bits. For example:
chmod 6755 fileHere, 6 represents 4 + 2, meaning both SUID and SGID are enabled.
Similarly:
chmod 3777 directoryHere, 3 represents 2 + 1, meaning SGID and Sticky Bit are enabled.
Note: setting these bits does not guarantee identical behavior on every file type or filesystem. Their effect depends on object type and operating system rules.
Common Mistakes When Working with Linux Special Permissions
Beginners and even experienced administrators sometimes misunderstand how special permission bits work. Here are some common mistakes to avoid:
1. Confusing SUID with Root Access
SUID does not automatically make every program run as root. It runs with effective user ID of its owner. Root privileges are involved only when file is owned by root and relevant execution conditions are satisfied.
2. Assuming SGID Give Everyone Write Access
SGID does not automatically grant write permissions to group members. It primarily controls effective group identity on executable files and group inheritance on directories. Ordinary directory permissions must still be configured correctly.
3. Thinking Sticky Bit Prevents All File Deletion
Sticky Bit does not make directory completely read-only. Users with appropriate directory permissions can still create files and remove their own files. It restricts removal and renaming of files owned by other users, subject to administrative privileges.
4. Ignoring Special Permission Security Risks
Unnecessary SUID and SGID permissions can introduce security risks. Administrators should audit these permissions and ensure that only trusted programs receive them.
5. Using Incorrect Numeric Permissions
Always remember special permission values, as using wrong first digit can enable different permission than intended.

Best Practices to Manage Linux Special Permissions
Follow mentioned practice to maintain secure Linux environment:
- Audit SUID and SGID files: Regularly review executables with special permission.
- Use least privilege: Grant only permissions required for program or user.
- Configure shared directories carefully: Use SGID when consistent group ownership is required.
- Enable Sticky Bit where appropriate: Protect files inside world-writable shared directories.
- Review file ownership: Check both owner and group before modifying permissions.
- Avoid unnecessary root-owned SUID programs: Keep privileged executables to minimum.
- Verify changes: Use “ls -l”, “ls -ld”, and “find” to confirm permission configuration.
- Test permission changes: Verify application and shared directories continue working as expected.
Following these practices can help reduce permission-related security risks and improve Linux system administration.
Key takeaways
- Understand difference between SUID, SGID, and Sticky Bit
- Check file and directory permissions before making change
- Use SUID for controlled privileged program execution
- Apply SGID to maintain consistent group ownership in shared directories
- Enable Sticky Bit on shared directories such as “/tmp”
- Remember numeric value, SUID (4), SGID (2), and Sticky Bit (1).
- Identify special permissions using lowercase “s”, uppercase “S”, lowercase “t”, and uppercase “T”.
- Use “chmod” to manage special permission bit
- Use “find” to identify SUID and SGID files.
- Follow the principle of least privilege to improve Linux system security
Conclusion
Understanding Linux file permissions, including SUID, SGID, and Sticky Bit, is essential for managing user access and securing shared directories. By using right chmod commands, regularly checking permissions, and following principle of least privilege, you can troubleshoot access issues more effectively and maintain secure and reliable Linux environment.
By applying these practice, you can manage Linux file permissions more confidently and maintain safer, more reliable Linux environment.
FAQs
What’s difference between SUID, SGID, and sticky bit?
Setting SUID shifts effective user ID of eligible program to match file owner during execution. SGID change its effective group ID or make new entries inherit directory’s group. Sticky bit restrict deletion and renaming inside directory.
Why is Sticky Bit used on the /tmp directory?
“/tmp” directory allows multiple users and applications to create temporary files. Sticky Bit prevents ordinary users from deleting or renaming files owned by other users, helping protect shared temporary data.
What does lowercase “s” and “t” mean in Linux file permissions?
Lowercase “s” represents enabled SUID or SGID bit in relevant execute permission position. It also indicates that corresponding execute permission is enabled.
Lowercase “t” indicates that Sticky Bit is enabled and directory’s execute permission for others is also enabled.
What does uppercase “S” and “T” mean in Linux permissions?
Uppercase “S” indicates that SUID or SGID is enabled, but corresponding execute permission is not enabled.
Uppercase “T” indicates that Sticky Bit is enabled, but directory’s execute permission for others is not enabled.
Are SUID and SGID security risks?
They are not generally security vulnerabilities. However, improperly configured or vulnerable SUID and SGID programs create security risks because they execute with privilege beyond those of user who launches them.
About the author
Meghna Meghwani is a technical writer focused on Linux, Ubuntu, VPS hosting, server management, WordPress, PHP, Node.js, cloud hosting, and DevOps. She creates beginner-friendly tutorials, practical hosting guides, troubleshooting articles, and server security content designed to help developers and businesses manage applications and servers more efficiently.
