LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-27-2015, 11:33 AM   #1
sudz28
LQ Newbie
 
Registered: Nov 2008
Location: Finksburg, Maryland
Posts: 7

Rep: Reputation: 1
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?
 
Old 02-27-2015, 11:55 AM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,863

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
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

Last edited by jailbait; 02-27-2015 at 11:56 AM.
 
1 members found this post helpful.
Old 02-27-2015, 12:05 PM   #3
sudz28
LQ Newbie
 
Registered: Nov 2008
Location: Finksburg, Maryland
Posts: 7

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by jailbait View Post
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I include subdirectories in a chown? newbiesforever Linux - General 4 07-20-2010 10:45 AM
Apache mod_rewrite Subdirectories and IP question mgichoga Linux - Server 0 08-12-2009 09:42 AM
chown question marsguy Linux - General 2 09-29-2005 12:48 PM
ls question: how to avoid listing contents of subdirectories learnfast Linux - Newbie 2 03-09-2005 09:59 AM
question about chmod and subdirectories Lleb_KCir Linux - General 2 07-28-2004 10:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration