chmod 777 on all directories below...how do I do that using the "find" command? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

chmod 777 on all directories below...how do I do that using the "find" command?

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-04-2001
Neko Neko is offline
Registered User
 
Join Date: Jun 2001
Last Activity: 13 October 2002, 4:55 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
chmod 777 on all directories below...how do I do that using the "find" command?

I've got 100 directories that each have 2 directories with in them.
Structered like this:
/home/domains/domain1/
through to
/home/domains/domain100/

and those 2 directories mentioned above are here:
/home/domains/domain1/directory1/
/home/domains/domain1/directory2/
through to
/home/domains/domain100/directory1/
/home/domains/domain100/directory2/

I need to chmod 777 on /directory1/ and /directory2/

How can I do this really quickly using the find command?
I had to chmod 755 on .cgi files in those directories and I did that using this command:

find . -name "*.cgi" -exec chmod 755 {} \;

How do I modify that command to chmod 777 on all directories but not the files in those directories?
Sponsored Links
    #2  
Old 06-04-2001
alwayslearningunix
Guest
 
Posts: n/a
It's clear the "domain" directory is not a universal name and so it's hard to use one find command to chmod all the directories under these "domain" directories - I am presuming you don't want the actual "domain" directories chmodded?

If there are no other directories, other than the ones you wish to operate the chmod command on, in /home/domains you can issue this command:

find /home/domains/*/ -type d -exec chmod 777 {} \;

Which will chmod all the directories under all the directories under /home/domains/domains1-100 - if you get what I mean

Another way to do it is to make a file which contains all the directory names under /home/domains under which you want the directories chmodded - which you may have if this is a commercial hosting service (an administration file of users/domain names would contain this information).

Put that file in the directory from which you can then issue this command on the command line;

filelist=the file with the list of directories
[cr] = carriage return:

for x in `cat filelist` [cr]
do [cr]
find /home/domains/$x/ -type d -exec chmod 777 {} \; [cr]
done [cr]

Hope this helps.

Regards

Sponsored Links
    #3  
Old 06-04-2001
Neko Neko is offline
Registered User
 
Join Date: Jun 2001
Last Activity: 13 October 2002, 4:55 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you very much


Thank you very much. That just saved me a tonne of work
    #4  
Old 06-04-2001
Optimus_P Optimus_P is offline Forum Advisor  
flim flam flamma jamma
 
Join Date: May 2001
Last Activity: 24 March 2008, 9:43 PM EDT
Location: Chicago IL, USA
Posts: 1,006
Thanks: 0
Thanked 2 Times in 1 Post
wouldnt chmod -R 777 /home/domains/*

effectivly do the same things as

find /home/domains/*/ -type d -exec chmod 777 {} \;
??
Sponsored Links
    #5  
Old 06-05-2001
alwayslearningunix
Guest
 
Posts: n/a
chmod -R /home/domains/* would recursively change the permissions on everything underneath the stated path name. Neko only wanted to change the permissions on the directories under the path name he stated. Thus the find command allows us to specify a condition (-type d) on which to operate the chmod command, which will only affect directories, not files.

Regards.
Sponsored Links
    #6  
Old 06-05-2001
Optimus_P Optimus_P is offline Forum Advisor  
flim flam flamma jamma
 
Join Date: May 2001
Last Activity: 24 March 2008, 9:43 PM EDT
Location: Chicago IL, USA
Posts: 1,006
Thanks: 0
Thanked 2 Times in 1 Post
got ya.
Sponsored Links
    #7  
Old 07-12-2001
bizlink bizlink is offline
Registered User
 
Join Date: Jul 2001
Last Activity: 13 July 2001, 7:36 AM EDT
Location: Orlando, FL
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question New dedicated server and I'm a little confused

I am not entirely new to unix or telnet....but advanced would
be a huge stretch of the imagination.....

I am trying to chmod a directory via root and I'm getting a
no such file or directory message?

correct me if I'm wrong but you simple go to the directory
you want to change permissions on and run this command,
chmod -r 777

Tony
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with "find" and "grep" command pstein Shell Programming and Scripting 5 09-30-2011 10:04 AM
awk command to replace ";" with "|" and ""|" at diferent places in line of file shis100 Shell Programming and Scripting 7 03-16-2011 08:59 AM
Using "find" in restricted directories forstudy3 UNIX for Dummies Questions & Answers 2 01-04-2010 08:17 AM
"find command" to find the files in the current directories but not in the "subdir" swamymns Shell Programming and Scripting 9 07-22-2008 11:23 AM
Listing only directories in the current working directory using the "ls" command igandu UNIX for Dummies Questions & Answers 2 05-12-2006 04:47 AM



All times are GMT -4. The time now is 05:23 AM.