LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
 
Thread Tools
Old 07-23-2004, 02:17 PM   #1
Risc91
Member
 
Registered: Jan 2002
Location: Macomb, MI
Distribution: Ubuntu|Red Hat ES|AIX
Posts: 161
Thanked: 0
chmod recursion -- files only


[Log in to get rid of this advertisement]
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
Risc91 is offline     Reply With Quote
Old 07-23-2004, 02:45 PM   #2
zorba4
Member
 
Registered: Feb 2004
Location: Paris
Posts: 398
Thanked: 0
"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 04:12 AM..
zorba4 is offline     Reply With Quote
Old 07-23-2004, 03:20 PM   #3
Risc91
Member
 
Registered: Jan 2002
Location: Macomb, MI
Distribution: Ubuntu|Red Hat ES|AIX
Posts: 161
Thanked: 0

Original Poster
good call. Thanks for the help!
Risc91 is offline     Reply With Quote
Old 07-23-2004, 05:00 PM   #4
zorba4
Member
 
Registered: Feb 2004
Location: Paris
Posts: 398
Thanked: 0
You're welcome
zorba4 is offline     Reply With Quote
Old 07-23-2004, 11:09 PM   #5
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,596
Thanked: 12
The first find should work w/o vi.

Code:
find /usr/lib/whatever -type f -name '*.ext' -exec chmod 444 {} \;
crabboy is offline     Reply With Quote
Old 07-22-2007, 05:12 AM   #6
diederick76
LQ Newbie
 
Registered: Jul 2004
Posts: 5
Thanked: 0
If your files contain spaces, backslashes, etc., do this instead:

find . -type f -print0 | xargs -0 chmod 444
diederick76 is offline     Reply With Quote
Old 06-20-2008, 04:16 PM   #7
unclecameron
LQ Newbie
 
Registered: Feb 2004
Location: Selma, Oregon
Distribution: Debian Lenny
Posts: 5
Thanked: 0
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
unclecameron is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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


All times are GMT -5. The time now is 05:50 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration