Re: what is the sticky bit?
Paul Miller wrote:
>
> I know this is a really stupid question.. but what is the sticky bit?
>
The sticky bit overcomes a problem with file permissions in Unix.
Specifically, the ability to create/delete a file in a given directory
depends on the *directory permissions*. When the sticky bit is set,
on a directory, the *owner* of files in that directory may remove
the files. An example will make this clear. Suppose my system has
a user, 'foo'. Let us assume the following commands are run by
someone logged in as root:
mylinux# cd ~foo
mylinux# echo 'I dare you to delete this' > make_my_day
mylinux# chmod 600 make_my_day
mylinux# pwd
/home/foo
mylinux# ls -l make_my_day
-rw------- 1 root root 0 Oct 1 11:11 /home/foo/make_my_day
mylinux#
Now user foo logs in and does the following:
mylinux$ whoami
foo
mylinux$ pwd
/home/foo
mylinux$ cat make_my_day
cat: make_my_day: Permission denied
mylinux$ ls -ld .
drwx--x--x 27 foo foo 3072 Oct 1 11:13 .
mylinux$ rm make_my_day
rm: remove `make_my_day', overriding mode 0600? y
mylinux$ ls -l make_my_day
ls: make_my_day: No such file or directory
mylinux$
Suprised?! Don't be. In a unix file system a directory is basically
a special "file". The act of creating or deleting a file from a
directory consists (obviously there's a little more which must happen)
of creating/removing "entries" in this special file. Thus it is the
permissions on a *directory* which determine whether or not a file
may be created-in/removed-from a directory.
Anytime you want to have a directory be "shared" by many users, this
type of behavior causes problems: if you make the directory writable,
so that anyone can create a file in the directory, you also make it
so that anyone can delete a file from the directory, *regardless* of
who owns the file. Usually, what you want is for anyone (or anyone
in a given group) to be able to be able to create file in the shared
directory but only allow the *owner* of the file to delete (or modify)
the file. The sticky bit makes this possible.
--
Jens B. Jorgensen
jjorgens@bdsinc.com
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: