• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 826
  • Last Modified:

Linux find with -or -exec

I have openSuSE 11.0

I'm using the following to Linux commands but I thought it should be possible to put them into one command:

find /data -type d -group users -exec chmod 774 {} \;
find /data -type f -group users -exec chmod 774 {} \;

I tried this but it didn't work:

find /data -type d -group users -or  -type f -group users -exec chmod 774 {} \;

because the -exec command only gets the results from the last -type sub-command. I thought this might be possible:

find /data -type d -group users -exec chmod 774 {} \;  -type f -group users -exec chmod 774 {} \;

but it seems excessive so I didn't try it. Anyone know the best way to make these two sub-commands work in one find command or should I just do this another way?
find /data -type d -group users -exec chmod 774 {} \;
find /data -type f -group users -exec chmod 774 {} \;

Open in new window

0
RegProctor
Asked:
RegProctor
  • 3
  • 2
1 Solution
 
amit_gCommented:
find /data \( -type d -o -type f \) -group users -exec chmod 774 {} \;
0
 
RegProctorAuthor Commented:
Works like a charm, thanks! I missed the backslash in front of the brackets for the shell when I tried it like this.
0
 
TintinCommented:
Why do you want 774 perms on dirs and files.  That's a strange permission to use.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
RegProctorAuthor Commented:
I have special needs and I am experimenting, I am programmer and I recently built two openSuSE computers as an exercise to learn Linux. One is a server (web and data on my local network) the other my development computer. I also hook a windows computer up through samba. All in all, just playing to learn rather than blindly following what people might consider standard... in this case 755 & 644.

My full permission for what I am doing right now is 6774.
0
 
TintinCommented:
Fair enough, so long as you know exactly what affect perms of 6774 has on dirs/files.
0
 
RegProctorAuthor Commented:
Pretty much so. I would be fool to think I know it all, still learning but I learn by playing around with things and they are my systems so no one else can get hurt from anything I muck up. I did change the permission to 2774 though so that the user can change but not the group.

Funny thing though, that setting has no effect if the root user edits a file because the owner becomes root:root no matter what you set on the special bits... I guess the root user is all powerful, like it or not.

0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now