LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 10:33 AM   #1
sudz28
LQ Newbie
 
Registered: Nov 2008
Location: Finksburg, Maryland
Posts: 9

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, 10:55 AM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
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 10:56 AM.
 
1 members found this post helpful.
Old 02-27-2015, 11:05 AM   #3
sudz28
LQ Newbie
 
Registered: Nov 2008
Location: Finksburg, Maryland
Posts: 9

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



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 09:45 AM
Apache mod_rewrite Subdirectories and IP question mgichoga Linux - Server 0 08-12-2009 08:42 AM
chown question marsguy Linux - General 2 09-29-2005 11:48 AM
ls question: how to avoid listing contents of subdirectories learnfast Linux - Newbie 2 03-09-2005 08:59 AM
question about chmod and subdirectories Lleb_KCir Linux - General 2 07-28-2004 09:55 AM

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

All times are GMT -5. The time now is 01:22 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
Open Source Consulting | Domain Registration