Tuesday, January 27, 2009

Sticky bit permissions

Sticky Bit Permissions

Another special permission provides for greater security on directories. Originally, the sticky
bit was used to keep a program in memory after it finished execution to increase efficiency.
Current Linux systems ignore this feature. Instead, it is used for directories to protect files
within them. Files in a directory with the sticky bit set can be deleted or renamed only by the
root user or the owner of the directory.

Using Symbols

The sticky bit permission symbol is t. The sticky bit shows up as a t in the execute position of
the other permissions. A program with read and execute permissions with the sticky bit has
its permissions displayed as r-t.
Here’s an example:

# chmod +t /home/dylan/myreports
# ls -l /home/dylan/myreports
-rwxr-xr-t 1 root root 4096 /home/dylan/myreports


Using the Binary Method

As with ownership, for sticky bit permissions, you add another octal number to the beginning
of the octal digits. The octal digit for the sticky bit is 1 (001). The following example sets the
sticky bit for the myreports directory:
# chmod 1755 /home/dylan/myreports

The next example sets both the sticky bit and the User ID permission on the newprogs directory.
The permission 5755 has the binary equivalent of 101 111 101 101:
# chmod 5755 /usr/bin/newprogs
# ls -l /usr/bin/newprogs
drwsr-xr-t 1 root root 4096 /usr/bin/newprogs

No comments:

Post a Comment