recursive chmod that only affects directories?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users recursive chmod that only affects directories?
# 1  
Old 06-22-2007
recursive chmod that only affects directories?

The man page for chmod doesn't list a way to recursively change permissions on directories only, without affecting the files themselves.

Let's say that I wanted to change the permissions on the current directory and all subdirectories. I know I can write a bash script that would do this using find . -type d and parsing through the results, but there are over 100 Linux servers where I work and I don't want to have to add the script to each one of them. Is there any more elegant way that this can be done? Would the following work?

Code:
chmod 755 `find . -type d`

# 2  
Old 06-22-2007
Code:
find . -type d -exec chmod 755 {} \;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Recursive search for files and copy to new directories

So I have extremely limited experience with shell scripting and I was hoping someone could point out a few commands I need to use in order to pull this off with a shell script like BASH or whatnot (this is on OS X). I need to search out for filenames with account numbers in the name itself... (3 Replies)
Discussion started by: flyawaymike
3 Replies

2. UNIX for Dummies Questions & Answers

Change chmod on files in diff directories

I am looking for a small script to crawl through several directories and change a couple of files in each directory to read write status. Anyone have any ideas ? (5 Replies)
Discussion started by: zapper222
5 Replies

3. Shell Programming and Scripting

Recursive looping through files and directories

hi; i need a script which will go to all directories and subdirectories and print the filenames as follow; here i m printing only files listing in current directory reason i m doing this is coz i want to perform some operations according to filename achieved so cant use find command;... (4 Replies)
Discussion started by: ajaypadvi
4 Replies

4. Shell Programming and Scripting

Change Rights Recursive with chmod

Hello, i want just to change Rights for a few direcories anf files, but some directories must be exclude. How can i put the command chmod as chmod -R 755 * exclude toto tata where toto and tata are directories Could you help me for that or must I use the find command Thanks (2 Replies)
Discussion started by: steiner
2 Replies

5. Shell Programming and Scripting

Command to sort directories after a recursive find

find -type d -name "TC_*" | sort That's what I have so far... it finds the appropriate directories and then sorts them. But, when it comes to nested subdirectories, it only sorts relative to the first subdirectory. I want it to sort based on the directory at the end of the path. Does anyone know... (3 Replies)
Discussion started by: crimsondarkn
3 Replies

6. UNIX for Dummies Questions & Answers

chmod -R recursive flag

Hi, why can't I use the flag -R recursive ? ftp> chmod -R a+xwr kickstart usage: chmod mode remote-file ftp> chmod a+xwr kickstart 200 SITE CHMOD command successful thanks (2 Replies)
Discussion started by: aneuryzma
2 Replies

7. AIX

recursive archive directories and subdirectories

Hi everyone, Maybe this is simple question for many of you, but I get confused.:confused: How to archive a parent directory which contains some subdirectories and some files? I have searched this forum, there are some commands like tar,etc, I tried but can not be implemented in my system.... (6 Replies)
Discussion started by: wilsonSurya
6 Replies

8. UNIX for Advanced & Expert Users

chmod to parent and sub directories ?

Hi folk, Could you please give me command to give the rwx permissions to the parent and its sub directories ? Is it possible to fire one command or Script for giving permission to both the parent and its sub directories. I meant to say something like in recurcive. I am using AIX 5.2 ... (2 Replies)
Discussion started by: varungupta
2 Replies

9. UNIX for Dummies Questions & Answers

chmod for files and directories

Hi, OS - Unix, linux (all unix flavors) My requirement. To check directory/file exists and then change the permission of the directories/files. Iam trying to start with directory and here is my code in the file totalchange.sh (insideragain - is a directory, test1.txt - is a file under the... (2 Replies)
Discussion started by: kenkanya
2 Replies

10. UNIX for Dummies Questions & Answers

grep recursive directories

I am trying to locate a file or files with specific data in them. Problem is the file(s) could reside in any one of many directories. My question is. Is there a way of recursively greping directories for the file(s) with the data I am looking for. I have tried - 1. $HOME> grep 47518 | ls... (8 Replies)
Discussion started by: jagannatha
8 Replies
Login or Register to Ask a Question