Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-15-2005, 02:03 PM   #1
LQ Newbie
Registered: Feb 2004
Distribution: FC4
Posts: 19

Rep: Reputation: 0
chmod to only change permissions of directories

Hello everyone.
I am in need of a command (or even shell or perl script) that will allow me to recursively (-R) change the permissions on only directories, leaving existing regular file permissions alone. I will also need to then change only the file permissions, leaving the directory permissions in place.

In the end, I will need to list (ls) only directories, and then only files.

My need for this is to change all directory permissions to 755, while changing all files to 555 within a large directory structure (in a Linux and HP 11.x environment).

Last edited by lluciano; 08-18-2005 at 12:35 PM.
Old 08-15-2005, 02:08 PM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 257Reputation: 257Reputation: 257
Errmm.. a simple find and -exec would do the trick perhaps..

find /path-here-of-directories-you-want-to-change/ -type d -exec chmod 755 {} \;

Perhaps that'll get you started.. man find for more details, options, etc.
Old 08-17-2005, 03:14 PM   #3
LQ Newbie
Registered: Feb 2004
Distribution: FC4
Posts: 19

Original Poster
Rep: Reputation: 0
useful commands

Thanks for the help. Here are the commands that I ended putting together in the end:

This command will recursively change all directories that are 777 for example, to 775:
find path/ -perm 777 -type d -exec chmod 775 {} \;

This command will recursively change all files that are 777 to 775:
find path/ -perm 777 -type f -exec chmod 775 {} \;


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using chmod to recursively change directories / files [GOD]Anck Linux - Software 6 11-10-2008 07:16 PM
CHMOD directories.sub-directories.files zerojosh Linux - Software 2 11-19-2005 04:22 PM
Why doesn't a wildcard chmod change "dot" files/directories? jht2k Linux - General 1 08-09-2004 03:31 PM
Using chmod on directories rob19 Linux - Newbie 4 07-10-2004 05:37 AM
Cannot Chmod directories stelmed Slackware 4 05-19-2003 02:30 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:14 AM.

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