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. |
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.
|
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. |
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.
|
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 |
Quote:
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 {} \; |
@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? |
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. |
Quote:
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 . 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? |
All times are GMT -5. The time now is 08:05 AM. |