Skip to content

Sticky Bit

January 4, 2011

The sticky bits purpose is to prevent the accidental deletion of directories by other users other than the original owner who created the directory.

As you can see in the example below, the sticky bit is set on the directory below, this means that other users can not delete the directory only the owner of the directory can delete the folder : –

prompt> ls -dl /tmp

drwxrwxrwt 18 root root 4096 2010-12-31 20:25 /tmp

As you can see in the above example, the directory has a t which symbolises the directory has a sticky bit enabled on this directory, hence no one but root can delete this directory.

Below is an example of how to remove the sticky point from the above example to allow other users to delete the directory, please note it is not advisable to do this on the directory in the example, the example only serves as an example of how to enable/disable the sticky bits on a specific directory: –

prompt> chmod o-t /tmp ### Change modify others (o) privileges to take away the stick bit

prompt> ls -dl /tmp

drwxrwxrwx 18 root root 4096 2010-12-31 20:25 /tmp ### As you can see the sticky bit has been removed, i.e. there is no t that denoted that the sticky bit was enabled on the directory

To enable the sticky bit on the directory you use the same symbolic notation method to do so: –

prompt>chmod o+t /tmp ### This time add the sticky bit to the directory to enable it

prompt> ls -dl/tmp

drwxrwxrwt 18 root root 4096 2010-12-31 20:25 /tmp           ### As you can see the t denotes that the sticky bit has indeed been enabled on the directory

Summary

The main reason to use the sticky bit would be to prevent users deleting other users directories by accident

Advertisements

From → Linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: