LinuxQuestions.org
Help answer threads with 0 replies.
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 07-01-2003, 03:28 PM   #1
Peanut
LQ Newbie
 
Registered: Jun 2003
Location: The Loo
Distribution: RH 9
Posts: 12

Rep: Reputation: 0
chmod question and problem


I am trying to chmod all files with the extension of *.cgi in a folder and all of its sub folders. It does it for the folder that i am in but it won't do any of the subfolders.

I have been using

chmod -R 755 *.cgi



Can anyone tell me what i am doing wrong thanks.
 
Old 07-01-2003, 03:33 PM   #2
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
Shouldn't it be a small r for recursive? I thought the big R is for reverse.

So
Code:
chmod -r 755 *.cgi
should work.

*edit - Never mind, big R is recursive, little r isn't even an option. Try adding a -v so that it spits out any error messages, might help to track it down.*

slight

Last edited by slightcrazed; 07-01-2003 at 03:37 PM.
 
Old 07-01-2003, 03:39 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I don't think you can do it like that. It will chmod the files that match the pattern and since you don't allow for a directory it won't work. Sorry I can't think of a way to do it without a script.
 
Old 07-01-2003, 03:46 PM   #4
slightcrazed
Member
 
Registered: May 2003
Location: Lisbon Falls, Maine
Distribution: RH 8.0, 9.0, FC2 - 4, Slack 9.0 - 10.2, Knoppix 3.4 - 4.0, LFS,
Posts: 789

Rep: Reputation: 30
From chmod --help:

Code:
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
  or:  chmod [OPTION]... OCTAL-MODE FILE...
  or:  chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.

  -c, --changes           like verbose but report only when a change is made
  -f, --silent, --quiet   suppress most error messages
  -v, --verbose           output a diagnostic for every file processed
      --reference=RFILE   use RFILE's mode instead of MODE values
  -R, --recursive         change files and directories recursively
      --help              display this help and exit
      --version           output version information and exit

Each MODE is one or more of the letters ugoa, one of the symbols +-= and
one or more of the letters rwxXstugo.

Report bugs to <bug-fileutils@gnu.org>.
Sure sounds like you can do it recursively, but maybe that is only for directories like David said. Maybe try specifying the entire path to your starting directory, i.e.

Code:
chmod -R 755 /my/directory/*.cgi
Anyone else have any ideas?

slight
 
Old 07-01-2003, 03:54 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
How about creating "/bin/rchmod":
Code:
#!/bin/bash

for i in `find -name \*.$2`; do
echo "chmod $1 $i";
chmod $1 $i;
done
chmod 755 /bin/rchmod

cd to the base dir containing the cgi files then run:
rchmod 755 cgi
 
Old 07-01-2003, 05:29 PM   #6
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
Code:
chmod -R 755 `find . -name \*.cgi`
 
Old 07-01-2003, 10:59 PM   #7
Peanut
LQ Newbie
 
Registered: Jun 2003
Location: The Loo
Distribution: RH 9
Posts: 12

Original Poster
Rep: Reputation: 0
thanks for all the responses

david_ross: I am a major newb and want to know how i would create such file.

Thanks for the help you guys are providing
 
Old 07-01-2003, 11:03 PM   #8
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
just open up a blank document and type the following or copy/paste it, and then save it as the name rchmod...
then change the permissions like he said for you can execute it.
and then also like he said change to the base of the directory and issue the command that he mentioned.
 
Old 07-01-2003, 11:15 PM   #9
Peanut
LQ Newbie
 
Registered: Jun 2003
Location: The Loo
Distribution: RH 9
Posts: 12

Original Poster
Rep: Reputation: 0
thanks
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chmod question Napalm Llama Linux - General 2 06-17-2005 09:17 AM
chmod question tongar Linux - Newbie 2 01-30-2005 02:43 PM
chmod Question Rawr101 Linux - General 1 09-19-2004 03:17 AM
chmod question odious1 Linux - General 1 11-28-2003 11:41 PM
Question regarding chmod Yohhan Linux - Software 3 01-26-2003 02:24 AM

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

All times are GMT -5. The time now is 04:45 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