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

LVL 1
RegProctorAsked:
Who is Participating?
 
amit_gConnect With a Mentor Commented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.