LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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-07-2006, 12:35 AM   #1
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 804

Rep: Reputation: 157Reputation: 157
Recursive chmod with different values for files and directories?


I have a large heirarchical directory and file structure, many levels deep with lots of subdirectories at every level. There are many more files than directories. I wanted all the files to have permissions 640 and all the directories 750.

I issued a command like this
Code:
chmod -R 640 startdir
where "startdir" was my highest level starting point for my changes. Then I had to spend 30 minutes traversing the rather large directory tree to change the permissions on all the subdirectories to 750. It was tedious. Is there another way I could have rapidly changed all the files to 640 and all the subdirectories to 750 without having to modify the subdirectories one by painful one?
 
Old 06-07-2006, 12:42 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

chmod in combination with find can do that:

For files (-type f is the key):
find . -type f -exec chmod 640 {} \;

For directories (-type d)
find . -type d -exec chmod 750 {} \;

Man find for details.

Hope this helps.
 
Old 06-07-2006, 09:38 AM   #3
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 804

Original Poster
Rep: Reputation: 157Reputation: 157
Hey, thank you very much, druuna. That looks like the sort of thing I was hoping for, a way to differentiate a file from a directory.
 
  


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
[SOLVED] FTP: recursive chmod (separate for directories and files) mgmax Linux - Software 11 01-29-2011 09:06 AM
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
chmod recursive on files on dlublink Linux - Newbie 6 03-02-2005 09:45 AM
chmod directories and files seperately robeb Linux - General 2 05-23-2003 09:01 PM


All times are GMT -5. The time now is 08:49 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration