Monday, January 29, 2018

What is Linux sticky bit and how to set Linux sticky bit.

This article will quickly guide you about Linux Sticky bit. Also it will guide you about how to set Linux sticky bit.
Linux sticky bit

Linux Sticky bit

Sticky bit is an special permission on files as well as on the directories. Whenever you set Linux sticky bit on directory there will be a special restriction on the directory and files. In such case , normal user cannot remove or rename files or directories inside directory except the owner of directory and the root user although the directory is publicly writable.

Where we should use Linux Sticky bit?

We must implement or set Sticky bit in publicly writable directories. In such case normal user who is not an owner of the directory or file cannot remove or rename files inside it.

How to set Linux Sticky bit

In order to set or to remove sticky bit we must use “t” flag in the chmod command as below:
Example of Linux sticky Bit:
Lets create test directory which publicly writable in /tmp directory.
Make this directory publicly writable with below command:
Now set sticky bit using chmod command as below along with “t” flag:
Now if you do ls command you can able to special “t” permission for test directory as below:
Create sample file 1 2 3 4 using touch command inside the test directory.
In order to test this up I am login with normal user manmohan and change directory to /tmp/
Now try to remove “test” directory, System will deny this by saying “Operation not permitted” although the test directory is publicly writable as below:

How to unset sticky bit

In case you want to reverse the sticky bit or unset sticky bit use chmod with minus “t” flag as below:

In case you want to learn more about securing plain text file follow this article.

Download Free book

Get your free copy of Linux command line Cheat Sheet!!!!

Download This Book: Click Here!!

No comments:

Post a Comment