LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-21-2005, 11:27 AM   #1
nicedreams
Member
 
Registered: Jun 2003
Location: Phoenix, AZ
Posts: 112

Rep: Reputation: 17
CHMOD with an exclude?


Is there a way to CHMOD everything in a directory except for two directories?

Like on my web server I need to set 'chmod 707 -Rv .' but want to exclude egroupware and maybe another dir in the furture.

That seems the fastest way to me or I can go through 100 files and have to chmod them one at a time, but this is Linux and I know it's flexable enough for that.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 10-21-2005, 11:36 AM   #2
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
I would have thought the easiest thing to do is to chmod everything in the directory as you described, then unchmod the two directories that you don't want included.
 
Old 10-21-2005, 01:54 PM   #3
nicedreams
Member
 
Registered: Jun 2003
Location: Phoenix, AZ
Posts: 112

Original Poster
Rep: Reputation: 17
How do I unchmod something then?

I hope you don't mean reset the permissions, because egroupware and some other apps are very picky about their permissions on the web server and won't run unless they are perfect.
 
Old 10-21-2005, 02:03 PM   #4
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
I did mean reset the permissions. Just note what the permissions were beforehand, then reset them afterwards. You could automate this using a fairly straightforward shell script.
 
Old 06-15-2016, 09:28 AM   #5
trexdude_99
LQ Newbie
 
Registered: Jun 2016
Posts: 3

Rep: Reputation: Disabled
Smile CHMOD with an exclude

I know this thread is old, but this solution is still relevant to anyone who may be searching for the same thing. Do a find on the directory and pipe it to egrep -v to exclude a string then pipe to xargs to chown/chmod everything but the directory you want to exclude.

find /usr/directory | egrep -v "somedirectory" | xargs -i /bin/chmod 770 {} 2>/dev/null
 
Old 06-15-2016, 09:48 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by trexdude_99 View Post
find /usr/directory | egrep -v "somedirectory" | xargs -i /bin/chmod 770 {} 2>/dev/null
Whoa. Welcome to LQ!
But your suggested command is NOT SAFE for web servers on public-facing networks.
and the permissions are non-standard on a web server.
files = 644
directories (are also files) = 755
with VERY FEW exceptions.

Code:
find /path -type d ! -name somedirectory -exec chmod 755 {} \;
Enjoy the Goodness.

Last edited by Habitual; 06-15-2016 at 09:56 AM.
 
2 members found this post helpful.
Old 06-15-2016, 05:34 PM   #7
trexdude_99
LQ Newbie
 
Registered: Jun 2016
Posts: 3

Rep: Reputation: Disabled
@Habitual

My code was posted as an example of what could be done, and not meant to be specific to a web server. Maybe you should let the OP know that 707 is non-standard and not safe also?
 
Old 06-16-2016, 01:36 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
neither 707 nor 770 are safe.
i'm with habitual: it's important to point these things out in the most vehement terms possible.
don't post this even as "as an example of what could be done".
because people will go and actually do it.
 
3 members found this post helpful.
Old 06-16-2016, 11:22 AM   #9
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by trexdude_99 View Post
@Habitual

My code was posted as an example of what could be done, and not meant to be specific to a web server.
Examples. Yes, lovely examples. Arbitrary code from (sometimes) arbitrary fora pasted into arbitrary terminals,
by a guy who wants to "chmod 707 -Rv ." except for two directories sourced from "some guy" with 2 posts?
The net is dangerous enough.
And wtf 770?
Double Secret Probation!

nicedreams:
Warning: Do not even think about running
Code:
chmod 707 -Rv .
or
Code:
find /usr/directory | egrep -v "somedirectory" | xargs -i /bin/chmod 770 {} 2>/dev/null

It is not my recommendation.

In the interest of fairness,
Why 707? and what 2 directories?
What are you reading and where are you reading it?

Last edited by Habitual; 06-16-2016 at 11:28 AM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
exclude directory with cp hampel Linux - Software 3 06-04-2009 11:59 AM
tar --exclude --exclude-from cefn Linux - Software 4 10-11-2005 07:31 PM
What can we do if we type chmod ugo-x /bin/chmod ?????? bunny123 Linux - Software 3 02-01-2005 08:53 PM
tar exclude-from drisay Slackware 1 12-23-2004 01:10 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM

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

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