Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to find all the web folders that are 777. But I only want a list of the top folders.

So if there is an img dir that has folders in it that are also 777 I don't want them returned.

Basically I'm looking for a way to have find stop descending after finding a folder that's 777.

find /var/www/vhosts/ -type d -perm 777

Gives me


And all i want is the first one

share|improve this question
up vote 4 down vote accepted

Use the -prune flag.

find /var/wwwhosts/ -type -d -perm 777 -prune should show exactly what you want.

Edit: Here's what this is doing for me, I believe this is what you wanted?

# ls -l
drwxrwxrwx 4 root root 4096 Feb 25 14:21 c

# ls -l c
drwxr-xr-x 2 root root 4096 Feb 25 14:21 1
drwxrwxrwx 2 root root 4096 Feb 25 14:21 2

# find . -perm 777 -prune

# find . -perm 777 -prune -exec ls -ld {} \;
drwxrwxrwx 4 root root 4096 Feb 25 14:21 ./c
share|improve this answer
That will return everything except the 777 folders. Maybe I can find a way to prune if the parent is 777 ? – Slashterix Feb 25 '10 at 20:25
Really? What OS/Bash version are you running on? This works perfectly for me. All the prune does is prevent recursing any further into the directory. It still prints the output. – Christopher Karel Feb 25 '10 at 20:31
I just suck at reading! You win! Thanks for the answer! – Slashterix Feb 25 '10 at 21:11
Completely understandable. It's some pretty counter-intuitive behavior from prune. – Christopher Karel Feb 25 '10 at 22:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.