Home > Linux, Unix > Sticky bit

Sticky bit

Sticky bit

The most common use of the sticky bit today is on directories.
When the sticky bit is set, only the item’s owner, the directory’s owner, or the superuser can rename or delete files. Without the sticky bit set, any user with write and execute permissions for the directory can rename or delete contained files, regardless of owner.
Typically this is set on the /tmp directory to prevent ordinary users from deleting or moving other users’ files

Consider you have a directory “/test“.
The chmod it to “777“, this command gives permissions for all the users to read, write and execute.
If you run chmod +t /test and now the /test directory content is the following:

Example: ls -al /test
drwxrwxrwt 2 xarabas LP1 4096 Jun 13 2008 .
-rw-rw-r– 1 xarabas LP1 0 Jun 11 17:30 1.txt
-rw-rw-r– 1 mandrake LP2 0 Jun 11 22:52 2.txt

From the above example “xarabas” is the owner of the test directory (see the first row). “xarabas” can delete or rename the files 1.txt and 2.txt. “mandrake” can delete or rename the file 2.txt only.

Concluding, if the sticky bit is set for a /test directory, only the owner of that directory or the owner of a file can delete or rename a file within that directory.

Categories: Linux, Unix
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: