The most common use of the sticky bit today is on directories – files/ folders in that directory can only be renamed or deleted by the item’s owner, the directory’s owner, or the superuser.
Generally this is set on the /tmp directory to prevent ordinary users from deleting or moving other users’ files.
The sticky bit can only be set by superuser root w/ chmod command, it can be set using its octal mode 1000 or by its symbol t (s is already used by the setuid bit). For example, to add the bit on the directory /usr/local/tmp, one would type chmod +t /usr/local/tmp. Or, to make sure that directory has standard tmp permissions, one could also type chmod 1777 /usr/local/tmp.
In Unix symbolic file system permission notation, the sticky bit is represented by the letter t in the final character-place. For instance, on Solaris 8, the /tmp directory, which by default has the sticky-bit set, shows up as:
$ ls -ld /tmp
drwxrwxrwt 4 root sys 485 Nov 10 06:01 /tmp
If the sticky-bit is set on a file or directory without the execution bit set for the others category (non-user-owner and non-group-owner), it is indicated with a capital T:
# ls -l test
-rw-r–r– 1 root other 0 Nov 10 12:57 test
# chmod +t test; ls -l test
-rw-r–r-T 1 root other 0 Nov 10 12:57 test
Generally this is set on the /tmp directory to prevent ordinary users from deleting or moving other users’ files.
The sticky bit can only be set by superuser root w/ chmod command, it can be set using its octal mode 1000 or by its symbol t (s is already used by the setuid bit). For example, to add the bit on the directory /usr/local/tmp, one would type chmod +t /usr/local/tmp. Or, to make sure that directory has standard tmp permissions, one could also type chmod 1777 /usr/local/tmp.
In Unix symbolic file system permission notation, the sticky bit is represented by the letter t in the final character-place. For instance, on Solaris 8, the /tmp directory, which by default has the sticky-bit set, shows up as:
$ ls -ld /tmp
drwxrwxrwt 4 root sys 485 Nov 10 06:01 /tmp
If the sticky-bit is set on a file or directory without the execution bit set for the others category (non-user-owner and non-group-owner), it is indicated with a capital T:
# ls -l test
-rw-r–r– 1 root other 0 Nov 10 12:57 test
# chmod +t test; ls -l test
-rw-r–r-T 1 root other 0 Nov 10 12:57 test
No comments:
Post a Comment