Archive

Archive for the ‘Linux’ Category

Changing permissions for all directories in folder

December 6th, 2008

Ever run into a situation where you have a mixture of both files and folders in a directory and you only need to change the permission of the folder? Naturally the first thing that comes to mind is to do something like this

find . -type d -print | xargs chmod 755

But what happens if your folders have spaces? Using find that way will not escape the spaces instead the solution to this is to use find but in a slightly different manner

find . -type d -print0 | xargs -0 chmod 755

The -print0 tells find to terminate with zero so that whitespaces are recognized and the same goes for xargs as well.

Linux, sys admin

Taken from Shell-fu

December 2nd, 2008

This is taken from shell-fu.org still a pretty handy one liner though

aptitude search ~c | awk '{ print $2 }' | xargs aptitude -y purge

This will delete any packages that are not installed anymore which still has configuration files on the box

Debian, Linux, sys admin

deborphan and for loops

December 2nd, 2008

deborphan is a package in debian that list orphaned libraries in debian. Handy for removing libraries that is no longer needed on a server. The problem with deborphan is that it only lists packages that are orphaned but doesnt remove them, so I do this:

for i in `deborphan`; do sudo aptitude remove $i; done

I love BASH :D

Debian, Linux, sys admin