LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 07-23-2004, 01:17 PM   #1
Risc91
Member
 
Registered: Jan 2002
Location: Macomb, MI
Distribution: Ubuntu|Red Hat ES|AIX
Posts: 161

Rep: Reputation: 30
chmod recursion -- files only


Is there a way to change the permissions on all the files below a given directory? I thought it was as simple as:

chmod -R 444 /usr/lib/whatever/*.ext

but this is changing the permissions on everything below the given driectory, including and directories.

TIA
 
Old 07-23-2004, 01:45 PM   #2
zorba4
Member
 
Registered: Feb 2004
Location: Paris
Posts: 398

Rep: Reputation: 31
"find . -type f -print | xargs chmod 444 "shoud work, isn't it ?
If not, find . -print >myfile.sh
and vi myfile.sh removing the directories (they should not be soo many), and then
1,$s/^/chmod 444/
and sh myfile.sh.
I know, the vi way is not very clever, but it works without thinking more than two seconds, so why not ?

Last edited by zorba4; 07-24-2004 at 03:12 AM.
 
1 members found this post helpful.
Old 07-23-2004, 02:20 PM   #3
Risc91
Member
 
Registered: Jan 2002
Location: Macomb, MI
Distribution: Ubuntu|Red Hat ES|AIX
Posts: 161

Original Poster
Rep: Reputation: 30
good call. Thanks for the help!
 
Old 07-23-2004, 04:00 PM   #4
zorba4
Member
 
Registered: Feb 2004
Location: Paris
Posts: 398

Rep: Reputation: 31
You're welcome
 
Old 07-23-2004, 10:09 PM   #5
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
The first find should work w/o vi.

Code:
find /usr/lib/whatever -type f -name '*.ext' -exec chmod 444 {} \;
 
Old 07-22-2007, 04:12 AM   #6
diederick76
LQ Newbie
 
Registered: Jul 2004
Distribution: Arch
Posts: 6

Rep: Reputation: 1
If your files contain spaces, backslashes, etc., do this instead:

find . -type f -print0 | xargs -0 chmod 444
 
1 members found this post helpful.
Old 06-20-2008, 03:16 PM   #7
unclecameron
LQ Newbie
 
Registered: Feb 2004
Location: Selma, Oregon
Distribution: Debian Lenny
Posts: 5

Rep: Reputation: 1
also, if you need to change the permissions on the folder instead of the files, try this
Code:
find . -type d -print0 | xargs -0 chmod 755
 
1 members found this post helpful.
Old 09-14-2010, 06:17 PM   #8
obiwahn
LQ Newbie
 
Registered: Mar 2010
Location: germany
Distribution: debian sid, e17
Posts: 2

Rep: Reputation: 0
Code:
find /usr/lib/whatever -type f -name '*.ext' -exec chmod 444 '{}' \;
 
Old 09-16-2010, 09:12 AM   #9
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Using xargs is usually much quicker as it does not have to execute chmod for every file.
 
Old 09-16-2010, 10:11 AM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I'm not sure if it's available everywhere, but on some versions of find at least you can replace the final semicolon with a plus sign, in which case it will act in a way similar to xargs. That is, it will run only one or a few instances of the command, with all the files from find built into a single argument.
Code:
find /usr/lib/whatever -type f -name '*.ext' -exec chmod 444 '{}' \+
I couldn't find anything that definitively showed that aix find has it, but this generic "unix" man page lists it as an option. gnu find also has it, of course.

(What the heck? I just noticed that this thread is over 6 years old!)

Last edited by David the H.; 09-16-2010 at 10:21 AM. Reason: zombie thread!
 
1 members found this post helpful.
Old 09-16-2010, 12:07 PM   #11
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
Great tip David, learn something new every day. I just tried it on AIX 5.3 and it works, it does not work on AIX 5.1
 
Old 06-28-2011, 01:04 PM   #12
4rapiddev
LQ Newbie
 
Registered: Jun 2011
Posts: 1

Rep: Reputation: Disabled
Thank you.
 
Old 09-18-2012, 08:58 AM   #13
byrnify
LQ Newbie
 
Registered: Sep 2012
Posts: 3

Rep: Reputation: Disabled
Recursive chmod thread

So I went trawling the web for an elegant and simple solution to this and decided to write a little script for this myself.

It basically does the recursive chmod but also provides a bit of flexibility for command line options (sets directory and/or file permissions, or exclude both it automatically resets everything to 755-644). It also checks for a few error scenarios.

Check it out:
http://bigfloppydonkeydisk.blogspot....-files-or.html

Hope it helps!
 
Old 02-14-2016, 12:27 AM   #14
jazman334
LQ Newbie
 
Registered: May 2015
Posts: 4

Rep: Reputation: Disabled
Talking missing the boat

yah...ok...lets shoot self in foot here....UH people... Dont let my 15 year old AS degree bite you in the ass here! LEAST PERMISSIVE.
THIS IS LINUX for GODS SAKES! You REALLY want the UNIVERSE to READ, or WORSE your FILES? The fact that some server services REQUIRE ANYTHING other than 0 for the world bit is MIND BLOWING! If the service(is and should be) a part of the GROUP you are assigned to(in any way) then SHURELY the process already HAS the necessary permission to read or exec the files, IE: apache.

Yet apache wants at minimal read permissions here? I think something is askew somewhere in someone's logic. Your theory holds. Your implementation of it SUCKS! 640 for files, 750 for folders(must exec or cannot browse them) is the CORRECT permissions.

Obviously, with apache, the last bit must be 4 for some reason, even though you are USUALLY a part of the www group when setting it up.And Im also finding that one must own files as root to put them into www folder to begin with.They should only need www as a group set.Neither the world bit nor the files should be owned by root to get apache to work with them.THIS IS NOT the CASE, however.

Completely missed the boat.Next cruise sails in 30 minutes...

need to edit certain files only? (commmand hell....) try this:
find . -name "*php" -exec chmod 644 '{}' \; -print

Last edited by jazman334; 02-14-2016 at 12:29 AM. Reason: incomplete
 
Old 02-14-2016, 01:42 AM   #15
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by jazman334 View Post
yah...ok...lets shoot self in foot here....UH people... Dont let my 15 year old AS degree bite you in the ass here! LEAST PERMISSIVE...

Completely missed the boat.Next cruise sails in 30 minutes...
Boom! You just shot a four year dead reply to a twelve year dead thread... impressive! How's that foot?

Did they teach swimming in that degree program? The last boat sailed from here long ago!

Last edited by astrogeek; 02-14-2016 at 01:53 AM.
 
2 members found this post helpful.
  


Reply



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 deleted my files NonSumPisces Linux - Newbie 14 09-22-2007 11:37 PM
Can chmod affect `future' files? Rodolfo Medina Linux - General 4 08-17-2005 03:23 AM
chmod recursive on files on dlublink Linux - Newbie 6 03-02-2005 08:45 AM
tar: '--no-recursion' option doesn't prevent recursion Earl Parker II Slackware 12 08-17-2004 02:49 AM
chmod command not affecting files blueleft Linux - General 4 08-09-2003 11:26 AM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 05:55 AM.

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