How to sets a special restriction on the deletion of files | Sticky bit

In this post discussing one special on the directory which is called a sticky bit. This permission effect on the directory is users with write access can be removed or renamed .which is owned by their owners. the user cannot remove or force save the files owned by other users. This permission has no effect on the files.

The example of the can be seen in the of the / directory. In the tmp directory, users can copy their files but no one else can remove those files instead of that owners. The below image is showing permission on the tmp directory.

In place of other users, the small t in execute bit. without a sticky bit, every user can remove everyone else’s files in / directory because write permission has been already granted to all users on that directory.

Here I am going to show below the practical aspect. I am going to create one directory and giving full to the user group and others mean everyone can create files or directories and do a modification and also can remove other user files and directories inside that directory.

In the above screencast, I created a directory secure server and created two users user1 and user2. user1 created a file inside that directory /secureserver . User2 delete that testfile_u1, which is owned by user1.

Afet Sticky bit implementation

So in the next steps, I am going to implement special on others that are Sticky Bit. Command to use set the sticky bit on the directory is below through number and letter format below.

 # chmod o + t  directory_path 
OR
 # chmod 2777 directory_path 
Sticky Bit Implementation

After sticky bit implementation, the users can not delete other users’ files. The error produces if a user tries to delete another user file, it says “Operation not permitted “.

Hope you understand the uses this concept . comment below if you have any query ?

About Sachin Gupta

I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009.Linux rocks!

Have any Question or Comment?

Leave a Reply

Your email address will not be published.