Last Updated on 11 hours by Sachin G
This post explains the concept and application of the sticky bit in Linux file systems. It details how setting the sticky bit on directories restricts file deletion, ensuring that only file owners can delete their files, even in shared directories. This sticky bit permission does not affect the files.
An example of the sticky bit can be seen in the permissions section of the /tmp directory. In the tmp directory, users can copy their files but no one else can remove those files instead of the owners. The image below shows permission on the tmp directory.
In place of other users, permission the small t in execute bit. without a sticky bit, every user can remove everyone else’s files in /tmp directory because write permission has been already granted to all users on that directory.
Here I am going to show the practical aspect. I am going to create one directory and give full permission to the user group and others, meaning everyone can create files or directories and make modifications, and also can remove other users files and directories inside that directory.
In the above screencast, I created a secure server directory 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 permissions on others that are Sticky Bit. The command to use set this special permission bit on the directory is below in number and letter format below.
# chmod o + t directory_pathOR
# chmod 2777 directory_path
After this special permission implementation, the users can not delete other users’ files. The error occurs if a user tries to delete another user’s file; it says “Operation not permitted “.
Hope you understand the uses of this concept. Comment below if you have any query?
I’m Sachin Gupta — a freelance IT support specialist and founder of Tech Transit. I’m certified in Linux, Ansible, OpenShift (Red Hat), cPanel, and ITIL, with over 15 years of hands-on experience. I create beginner-friendly Linux tutorials, help with Ansible automation, and offer IT support on platforms like Upwork, Freelancer, and PeoplePerHour. Follow Tech Transit for practical tips, hosting guides, and real-world Linux expertise!