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


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers chmod 777 on all directories below...how do I do that using the "find" command?
# 1  
Old 06-04-2001
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?
# 2  
Old 06-04-2001
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 Smilie

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

alwayslearningunix
# 3  
Old 06-04-2001
Thank you very much


Thank you very much. That just saved me a tonne of work Smilie
# 4  
Old 06-04-2001
wouldnt chmod -R 777 /home/domains/*

effectivly do the same things as

find /home/domains/*/ -type d -exec chmod 777 {} \;
??
# 5  
Old 06-05-2001
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.
alwayslearningunix
# 6  
Old 06-05-2001
got ya.
# 7  
Old 07-12-2001
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

4. AIX

find command to list all the 777 files and directories owned by root user

Hi I'm logged in to an AIX box now and we need to do an audit on this box. cbssapr01:# pwd / Which command will show all the files and directories owned by root user with permissions as 777 ? (8 Replies)
Discussion started by: newtoaixos
8 Replies

5. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Dummies Questions & Answers

Using "find" in restricted directories

Hi, I would like to know is there any way to find/search filenames or directories inside the directories which has resticted permission. When we use normal "find" command it returns "permission denied" message for the root directories or directories with restricted permissions. Thanks (2 Replies)
Discussion started by: forstudy3
2 Replies

8. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

9. Shell Programming and Scripting

bash: cd command to access "strange" directories

I have a problem using bash. Simply, I cannot find the right command (if there's one!) to enter in the "- Arch_02 -" directory. As you can see, the name begins with a hyphen and this is causing some trouble: localhost arch2 # pwd /mnt/arch2 localhost arch2 # ls -l total 4 dr-x------ 1 root... (3 Replies)
Discussion started by: robotronic
3 Replies

10. UNIX for Dummies Questions & Answers

Listing only directories in the current working directory using the "ls" command

Hello All, I am trying to list only directories in my current directory using the command "ls -d". But the output only contains the default directory "." and doesn't list the rest of the directories in the working directory. Can anyone explain why this is happening (2 Replies)
Discussion started by: igandu
2 Replies
Login or Register to Ask a Question