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

Notices


Reply
  Search this Thread
Old 06-14-2007, 09:37 PM   #1
Four
Member
 
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, 10:31 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 164Reputation: 164
This is something that find can help with. For example:
Code:
find /starting/point -type d -exec chmod -c 0755 {} \;
find /starting/point -type f -exec chmod -c 0644 {} \;
 
Old 06-15-2007, 01:48 AM   #3
pixellany
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
 
  


Reply


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 01:18 AM
CHMOD directories.sub-directories.files zerojosh Linux - Software 2 11-19-2005 04:22 PM
How to chmod -R on directories only? jdupre Linux - Newbie 3 11-13-2004 12:45 AM
Using chmod on directories rob19 Linux - Newbie 4 07-10-2004 05:37 AM
chmod directories only vrillusions Linux - General 4 05-21-2003 09:02 PM


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

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