Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-14-2007, 08:37 PM   #1
Registered: Aug 2005
Posts: 298

Rep: Reputation: 30
chmod only directories

Hey how can I have chmod effect only directories? and how can I have it effect only files. I want to set a bunch of directories, and files permisions however I want to set them different permisions.

Thank you!
Old 06-14-2007, 09:31 PM   #2
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,138

Rep: Reputation: 166Reputation: 166
This is something that find can help with. For example:
find /starting/point -type d -exec chmod -c 0755 {} \;
find /starting/point -type f -exec chmod -c 0644 {} \;
Old 06-15-2007, 12:48 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
It depends on the overall directory structure and which files you want to change. The solution above changes all files (or all directories) in the "/starting/point", but not below.

Other tools to consider:
ls -l|grep '^d' ___to list all directories in the current directory

ls -l|grep -v '^d' ___to list all files (not directories)

ls -lR|grep '^d' ___to list all directories in the current dir AND BELOW

chmod 777 `ls -l|grep '^d'`
___to change all directories in the current directory to 777 permissions

(Note the difference between single quote (') and backtick (`) )
Having the ls command in backticks is equivalent to the "-exec" approach


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
chmod directories??? rev_swid Debian 17 04-13-2006 12:18 AM
CHMOD directories.sub-directories.files zerojosh Linux - Software 2 11-19-2005 03:22 PM
How to chmod -R on directories only? jdupre Linux - Newbie 3 11-12-2004 11:45 PM
Using chmod on directories rob19 Linux - Newbie 4 07-10-2004 04:37 AM
chmod directories only vrillusions Linux - General 4 05-21-2003 08:02 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:48 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration