recursive type based chmod

Here’s a cool little script that will recursively chmod, giving a permission based on whether it’s dealing with a file or a directory. This is very convenient when you want to add that +x to directories but not files.

find $1 -type f -exec chmod $2 {} ;
find $1 -type d -exec chmod $3 {} ;

Go ahead and edit /usr/bin/chmod_script, copy paste these 2 lines in there, then issue a chmod 755 /usr/bin/chmod_script as root, that’s it!

Usage syntax is as follows:

chmod_script <directory_to_start_the_recursion_in> <permissions_for_files> <permissions_for+directories>

so if I want to use it on /var/www do:

chmod_script /var/www 644 755

Enjoy!

first!

Ca fait un bail que je vois passer le phenomene des blogs sans m’y interesser. Avec le changement complet d’Akrin je crois qu’il est temps de se mouiller les pieds. A moi le social networking, le web 2.0, et tout le tralala! Je vais vous podcaster la blogosphere comme si il n’y avait pas de lendemain.

Ca risque d’etre assez geeky faudra pas s’inquieter.

De quoi on va parler?

  • programming
  • vie aux states
  • video games
  • cats

That’s all folks