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 need to find all folders on a Linux server with directory name config and put a .htaccess in that directory containing "deny from all".

I'm currently trying to run:

find /home/www/sites/ -type d -name "config" -exec sh -c 'echo "deny from all" > .htaccess' \; 

But it doesn't work.

What have I missed?

share|improve this question
Define "doesn't work". – womble Jul 28 '12 at 2:35
up vote 1 down vote accepted


find /home/www/sites/ -type d -name "config" -exec sh -c 'echo "deny from all" > {}/.htaccess' \;
share|improve this answer
Thanks Womble - worked! – DmitrySemenov Jul 28 '12 at 2:54

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.