LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 03-27-2004, 04:09 PM   #1
Meta42
LQ Newbie
 
Registered: Aug 2003
Location: Sweden
Distribution: Fedora 7, IPCop
Posts: 14

Rep: Reputation: 0
Question recursive change of permissions


Hi,

I wan't to change the permissions of a folder and it's subfolders and all the files in it, but I can't figure out how to do it and get the folders and files to have different permisions from eachother?

After some man reading and googling I tried first setting all to 775, and then I wanted to change all the mp3 files to 664.
so my latest atempt was:

chmod -R 775 *
ls -R | grep 'mp3' || chmod 664

But that last command did nothing

ls -R | grep 'mp3' | more

gave me a list of all the mp3 files, not sure what exactly I'm doing wrong

Is there some way of doing this, that dosn't require that I go thru thousands of files one by one ?
 
Old 03-27-2004, 04:12 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
"chmod -R 755 *.mp3" should work
 
Old 03-27-2004, 04:16 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Or my all-time favourite, find! :)

find </start/dir/name> -iname "*mp3" -exec chmod 664 {} \;


Cheers,
Tink
 
Old 03-27-2004, 04:17 PM   #4
Meta42
LQ Newbie
 
Registered: Aug 2003
Location: Sweden
Distribution: Fedora 7, IPCop
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by acid_kewpie
"chmod -R 755 *.mp3" should work
Thats what I thought first to, but it dosn't seam to work since none of the folder names contains ".mp3"

chmod: failed to get attributes of `.mp3': No such file or directory

But thank you for the quick reply



Trying the Find command now .. *chuck chuck* ooh that took a while I have to many mp3's hehe, but it worked WEEEE!

Thank You Tinkster!

Last edited by Meta42; 03-27-2004 at 04:20 PM.
 
Old 03-27-2004, 04:21 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
oh duhh.... yeah that was a stupid suggestion sorry. the *.mp3 will simply match the existing files in that directory, not a patten match for chmod. what a fool.....

listen to Tink instead.
 
Old 03-27-2004, 04:22 PM   #6
Muzzy
Member
 
Registered: Mar 2004
Location: Denmark
Distribution: Gentoo, Slackware
Posts: 333

Rep: Reputation: 30
If you want to stick with your original method - all you were missing was backticks:

chmod -R 775 `ls -R | grep 'mp3'`

or something like that *might* work. Give it a try.

Muzzy.
 
Old 03-27-2004, 04:22 PM   #7
AutOPSY
Member
 
Registered: Mar 2004
Location: US
Distribution: Redhat 9 - Linux 2.6.3
Posts: 836

Rep: Reputation: 31
*.mp3 not .mp3
 
Old 03-27-2004, 04:25 PM   #8
Meta42
LQ Newbie
 
Registered: Aug 2003
Location: Sweden
Distribution: Fedora 7, IPCop
Posts: 14

Original Poster
Rep: Reputation: 0
thx, all cli knowledge goes into my notebook, so I'll have more fun next time
 
Old 03-27-2004, 04:41 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by Meta42
Trying the Find command now .. *chuck chuck* ooh that took a while I have to many mp3's hehe, but it worked WEEEE!
Yep, it would
;)

Quote:
Thank You Tinkster!
Anytime :}


Cheers,
Tink
 
  


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
How to change permissions? SonoranFun Linux - Newbie 4 11-02-2004 10:10 AM
rox + recursive permission change for FILES only? NonSumPisces Linux - Newbie 9 08-11-2004 07:21 PM
Can't change permissions LitlJay Linux - Software 9 05-21-2004 01:41 PM
recursive file permissions does not change new files in same directory PAB Linux - Newbie 2 03-08-2004 12:27 PM
How Can I Change Permissions monkeymartin Linux - General 1 03-25-2003 12:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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