Creare una directory scrivibile ma non eliminabile

From RVM Wiki
Jump to navigation Jump to search

Make a directory sticky

If you want to ensure that a directory persists and isn't removed by accident, set the sticky bit by using

chmod +T directory_name

See this:

$ ls -lF
drwxrwxrwx    2 strike  strike   68 Aug 28 06:21 dropbox/
drwx------    2 strike  strike   68 Aug 28 06:21 mine/
$ chmod +t dropbox
$ ls -lF
drwxrwxrwt    2 strike  strike   68 Aug 28 06:21 dropbox/
drwx------    2 strike  strike   68 Aug 28 06:21 mine/

With the sticky bit set and with permissions set to all can read, write, and execute, everyone can place files in my drop box, but I am the only user who can remove files in the directory or remove the directory itself.

If you run ls -ld /tmp, chances are that your system-wide temporary directory, used widely as application scratch space, is sticky.

Riferimenti