sudo -s Got root?

1Aug/110

Git configs

Because  I never seem to remember them

Global git ignore

echo ".DS_Store" >> ~/.gitignore
git config --global core.excludesfile ~/.gitignore

My info

git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

Colorized outputs

git config --global color.branch auto
git config --global color.diff auto
git config --global color.interactive auto
git config --global color.status auto
31Jul/110

sudo while in vim

Ever had a time when you opened a file in vim and edited a bunch of stuff without realizing that its read-only, well this solves you from exiting out of the file and reopening the file with sudo

:w !sudo tee %
Filed under: Linux No Comments
13Apr/090

How to remove duplicate file

Taken from shell-fu

OUTF=rem-duplicates.sh;
echo "#! /bin/sh" > $OUTF;
find "$@" -type f -print0 |
xargs -0 -n1 md5sum |
sort --key=1,32 | uniq -w 32 -d --all-repeated=separate |
sed -r 's/^[0-9a-f]*( )*//;s/([^a-zA-Z0-9./_-])/\\\1/g;s/(.+)/#rm \1/' >> $OUTF;
chmod a+x $OUTF; ls -l $OUTF

Filed under: Linux No Comments
6Dec/080

Changing permissions for all directories in folder

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.

Filed under: Linux, sys admin No Comments
2Dec/080

Taken from Shell-fu

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

2Dec/080

deborphan and for loops

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