Posts tagged with "chmod"

chmod recursively – but folders only

Ever wanted to chmod all subfolders of a directory, without touching the files inside? I did. I know I’ve had this problem about a hundred times, googled it, found a solution – and then forgot about it again.

Well, here it is; quick and painless:

$ find . -type d -exec chmod xxx {} \;

The same works for files, of course – simply replace -type d by -type f. And don’t forget to replace xxx with the rights you wish to give.

If you’re a little paranoid like me and want to see what the command does, add a -print at the end so the whole command looks like

$ find . -type d -exec chmod xxx {} \; -print

Very handy for web servers when you want to give your www-data write and execute priviledges to all folders but not necessarily the files inside.