LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chown question for subdirectories (https://www.linuxquestions.org/questions/linux-newbie-8/chown-question-for-subdirectories-4175535288/)

sudz28 02-27-2015 10:33 AM

chown question for subdirectories
 
I have a directory structure and files I wish to change permissions on, but I don't want to change permissions on every file/subfolder along the way. Example: I want to chown all files in dir4 where my directory struture is:
/dir1/dir2/dir3/dir4/*
However, both dir3 and dir4 are owned by root:root so I need to change the ownership on those directories as well. But, if I do:
chown -R user:group /dir1/dir2/dir3/dir4/
...it will indeed make dir4 and it's files accessible, but it doesn't change dir3 - so folks still can't get to the files they need. I thought about doing:
chown -R user:group /dir1/dir2/dir3*
... but that will give users access not only to dir4 and it's files, but any other files under dir3 which I don't want.

My work around has been to do a chown on /dir1/dir2/dir3 and then a second chown on /dir1/dir2/dir3/dir4/, but I am thinking there has to be a way to do what I want in a single chown command - right?

jailbait 02-27-2015 10:55 AM

You need to use the chown command only on dir4 and its contents. For dir1, dir2,and dir3 you need to leave the ownership with root but change the permissions on those directories to 755 using the chmod command. But do not change the permissions on the contents of dir1, dir2, and dir3.

-------------------
Steve Stites

sudz28 02-27-2015 11:05 AM

Quote:

Originally Posted by jailbait (Post 5324311)
You need to use the chown command only on dir4 and its contents. For dir1, dir2,and dir3 you need to leave the ownership with root but change the permissions on those directories to 755 using the chmod command. But do not change the permissions on the contents of dir1, dir2, and dir3.

Thank you much sir! So I guess there really is no way in a single command to tell Linux "give this user:group ownership to dir4 and it's contents as well as the ability to get to them". But you're right, I'm better off to simply open up the access to dir3 and not actually change the ownership. Good tip!


All times are GMT -5. The time now is 08:20 PM.