Setting Sticky Bit recursively ONLY on directories
I have a folder that contains my group's website. The ownership of the entire directory is set to "www-data.website" (website being a group). I want to set the sticky bit on this directory such that if anyone creates a new file, either in the main directory or subdirectories, the ownership remains like above.
Q1: I have the sticky bit set on the main directory (drwxrwsr-x). But for some reason, some of the subdirectories don't have the sticky bit set. Is there a command I can use to change the sticky bit on DIRECTORIES ONLY (ie. not on the fiiles)? Q2: is there a sticky bit that I can set for the ownership (not group) so that it is always set to www-data? |
You could use find...
Code:
find /var/www/dir -type d -exec echo chmod 2755 {} \; |
Hi,
you are setting the sgid bit on the directory, not the sticky bit. As for your second question: The suid bit on a directory is ignored in Linux. But you can change ownership after the file has been created. I once did that using incron. You can monitor the directory with this daemon and take appropriate actions when the CREATE event is being triggered. In your case this would be a chown on the newly created file. |
Quote:
Thanks for the suggestion on incron. |
Quote:
Code:
# find /foo -type d -exec chmod g+s {} \; |
Quote:
|
All times are GMT -5. The time now is 11:22 AM. |