Monday, February 8, 2010

Sticky Bit

There is an interesting file protection mode called the sticky bit, which has a useful effect when applied to directories. If the sticky bit is set on a directory, files inside the directory may be renamed or removed only by the owner of the file, the owner of the directory, or the superuser even if the modes of the directory would otherwise allow such an operation. This is effective for temporary directories such as /tmp and /var/tmp which must be accessible to many authorized users. The following two commands have the same effect:

# chmod a+rwxt /tmp
# chmod 1777 /tmp

allows anyone to create, read, and write files in /tmp, but only the file owner, the directory owner, or root can delete files

2 comments:

  1. By which command , how to check , whether sticky bit set on a directory or file or not ?

    ex: on /tmp how to check , whether sticky bit set or not, which command

    ReplyDelete
  2. ls -ld /tmp this command will give output like below
    drwxrwxrwt 104 bin bin 14336 Aug 7 00:59 /tmp

    the last 't' means its stickybit.

    ReplyDelete