LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-14-2012, 10:23 PM   #1
spezticle
Member
 
Registered: May 2010
Distribution: Ubuntu 10.04
Posts: 30

Rep: Reputation: 0
Question chmod directories or files with recursive. not both


Sorry if the subject sounds confusing.

What i'm trying to do apply permissions to everything in "./Directory/" and up all 755 if it is a directory but 644 if it is not a directory.

So i was thinking a command like
Code:
chmod 755 ./ -Rv |grep drwx
or something like that, but obviously that doesn't work.
 
Old 04-15-2012, 01:21 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Code:
find ./Directory -type d -exec chmod 755 {} \;
find ./Directory -type f -exec chmod 644 {} \;
Beware that will render any executables non-executable!

Last edited by catkin; 04-15-2012 at 01:29 AM. Reason: .Directory -> ./Directory
 
1 members found this post helpful.
Old 04-15-2012, 01:21 AM   #3
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 193Reputation: 193
If i understand your question correctly, I would use 2 find commands as such:
Code:
find ./Directory -type d -exec chmod 755 '{}' \;
This will find anything within ./Directory of type directory (d) and execute the chmod command on the results, represented by the '{}'.

You could then run a similar command, but modified to only find files (type f).
 
1 members found this post helpful.
Old 04-15-2012, 02:55 AM   #4
spezticle
Member
 
Registered: May 2010
Distribution: Ubuntu 10.04
Posts: 30

Original Poster
Rep: Reputation: 0
perfect. thanks. awesome that you both replied in the same minute with the same command haha
 
  


Reply

Tags
chmod



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
[SOLVED] Recursive delete specific files from sub-directories. guriinii Linux - Newbie 11 03-07-2011 10:41 AM
[SOLVED] FTP: recursive chmod (separate for directories and files) mgmax Linux - Software 11 01-29-2011 08:06 AM
chmod 775 to only the directories and chmod 664 to only the files? apachenew Linux - Security 6 09-27-2007 03:26 PM
Recursive chmod with different values for files and directories? Z038 Linux - Newbie 2 06-07-2006 08:38 AM
chmod recursive on files on dlublink Linux - Newbie 6 03-02-2005 08:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:43 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
Open Source Consulting | Domain Registration