What is Sticky bit or special permission in Linux?

In this article, you will learn about what is sticky bit in Linux?

The sticky bit is used in other sections of permission. It is applied only to the directory. If we look at the standard permission, other users can not access all files.

When we give all the permission, like read, write, and execute then the regular users can access all the files. But if they have all the permissions, they can delete that file as well. Here to save that file, we use the sticky bit.

If Sticky bit is enabled on a folder, the folder contents are deleted by only the owner who created them and the root user.

Understanding the concept of the Sticky bit

I’m creating a directory with name amit with the root user account, you can see in the below picture.

Here, the directory amit has below permission

d (It represents directory)

rwx (this is for user)

r-x (It is for the group)

r-x (this is for other)

Now, you can use the below command to give the sticky bit permission,

Symbolic mode

chmod o+t amit

here, o for others, t for a sticky bit and, amit is the file name, after running this command, you will get below changes,

sticky bit in linux

In the sticky bit,

Small t means, sticky bit present with execute (sticky bit + execute)

Capital T means, only sticky bit present

Absolute mode or Numerical or Octal mode

{Special Note:

In clubbed permission (7777) first, 7 represent SUID+SGID+Sticky bit
SUID value = 4
SGID value = 2
Sticky bit value = 1}

The command in octal method will be as below.

chmod 1755 amit

How to find all the sticky bit set file in Linux/Unix

find / -perm /1000

Here, I am looking for Sticky bit set files in / (root partition or root directory). If you are looking to another place, then change the / with your specific location.

Conclusion

In this tutorial, you learned about Sticky bit in Linux. It is special permission. We don’t generally need it. But you must know the sticky bit in Linux. I hope you understand, but if you have any questions, you can ask in the comment section.

Also, you can further read,

Leave a Reply