search
top

How to set a Directory Sticky Bit in Linux

There are times on Linux / Unix that you need to set the permissions on a directory so that only the owner and root can delete / rename files or sub-directories in the directory. This is true by default with the /tmp directory.

This is commonly referred to as the sticky bit.

If you want to keep the permissions the same on the directory and just add the sticky bit you can do this by using the chmod command with +t option.

We can see the results by using ls -al and we see t at the end of the output.

We can also set the permissions and the sticky bit using octal numbers with chmod. Using 1 and then the octal permissions is the way to achieve this.

With the same results.

You can remove the sticky bit by passing -t.

With the results.

Hope you find this helpful!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

top