creating directories with owner/permissions that stick
i have done this before when setting up squid but can not remember or find the command.
I would like to create directories with owners/permissions that stick. By that i mean: mkdir /store chown newowner /store chmod 770 /store mkdir /store/1 mkdir /store/2 is it possible (umask?)for /store/1 and /store/2 to end up with newowner and 770 during the mkdir process? Is there a command that will tell /store that every directory created under /store should have newowner and 770? I have been lurking for a while and found this forum to be very helpful. Thanks ahead. |
Do the mkdirs first, the use the -R switch (recursive) on the chmod & chown cmd. Don't forget the grp owner eg
chown -R owner:grp somedir |
thanks for the quick response.
I was looking for something besides a recursive. I remember a swith or a sticky permission of some sort that would say that anything under that certain directory would inherit permissions and owner from the parent. thanks anyway. |
Sounds like your confusing it with the 'sticky' bit. See section 6 here: http://www.zzee.com/solutions/unix-p...s.shtml#setuid
|
Yes. The owner of a directory can set the suid and sgid of the directory. Files created by other users will then inherit the owner and group of the parent directory. The permissions on a new file or directory will be masked according to your umask setting.
--- update: I tried it out with a directory I created on in my home directory. I created it as root and gave it 7777 permissions. A file I created there as a regular user had the group ownership of root but not the ownership. A directory I created there had the group of root but I was the owner. There may be a capability setting that doesn't allow suid on directories; and maybe there's a good reason why. --- If you have a directory structure that you want to create, you could use brace expansion to do it, and then use chown and chmod recursively. mkdir -p store/{1..10} This will create directory "store" with ten subdirectories "1".."10". |
All times are GMT -5. The time now is 10:03 AM. |