Understanding Special Permissions in Linux: SUID, SGID & Sticky Bit

Sonica SonawaneSonica Sonawane
2 min read

When it comes to Linux file system permissions, most users are familiar with the basic rwx model. But did you know Linux offers special permissions for even more control over files and directories?

These are:

  1. SUID (Set User ID)

  2. SGID (Set Group ID)

  3. Sticky Bit

Let’s break them down with clear examples using different user and directory names so it feels a little less textbook and a bit more practical.


🔐 1. SUID – Set User ID

The SUID bit is used on executable files. When a file with SUID is executed, it runs with the permissions of the file owner, not the user who runs it.

🧪 Example:

Let’s say we have a program backup.sh owned by the user linda, and we want another user, aarav, to run it with linda’s permissions.

chmod u+s backup.sh

Or using octal notation:

chmod 4755 backup.sh

To confirm:

ls -l backup.sh

You’ll see an s in the owner’s execute spot: rwsr-xr-x

To remove the SUID:

chmod u-s backup.sh

👥 2. SGID – Set Group ID

The SGID permission on a directory ensures that all new files and folders inside inherit the group ownership of the parent directory.

🧪 Example:

Suppose you have a team directory /project_phoenix with group devteam. You want all files created there to stay under that group, even if created by different users.

chmod g+s /project_phoenix

Or:

chmod 2755 /project_phoenix

To check:

ls -ld /project_phoenix

Look for the s in the group’s execute bit: rwxr-sr-x

To remove it:

chmod g-s /project_phoenix

🧷 3. Sticky Bit

This is most commonly used on shared directories like /tmp. When set, only the file's owner, directory owner, or root can delete the files within that directory—regardless of group permissions.

🧪 Example:

You create a shared directory /collab_space that multiple users can access, but you want users to only delete their own files.

chmod +t /collab_space

Or:

chmod 1777 /collab_space

To check:

ls -ld /collab_space

You’ll see a t at the end: rwxrwxrwt

To remove the sticky bit:

chmod -t /collab_space

🧠 Wrapping Up

Understanding and applying these special permissions helps you:

  • Execute programs safely with elevated privileges.

  • Maintain consistent group ownership in team folders.

  • Prevent accidental file deletion in shared directories.

In short, they give you more control, security, and collaboration power on multi-user systems.


✍️ Have you used these special permissions before? Share your stories or mishaps in the comments below!

0
Subscribe to my newsletter

Read articles from Sonica Sonawane directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sonica Sonawane
Sonica Sonawane

Hi, I'm Sonica! 👋 I’m currently diving into the world of DevOps, focusing on AWS, Docker, Kubernetes, Linux, and GitHub. My passion lies in automating systems, building cloud infrastructure, and optimizing workflows. I’m committed to continuous learning, hands-on projects, and sharing my journey with others in the tech community. Before shifting to DevOps, I worked in IT Sales, where I gained valuable skills in client communication, requirement gathering, and problem-solving. This experience taught me how to connect technical solutions to business needs, which has been instrumental as I transition into DevOps, where technical expertise and problem-solving go hand in hand. Now, I’m eager to apply my sales experience alongside my growing technical skills in cloud engineering and DevOps. Join me as I explore the latest trends, challenges, and solutions in the world of cloud computing!