Magic commands

bash_logoHere i will post all my favorite commands if you want to share others let me know:

Check for DOS attacks

netstat -anp|grep tcp|awk ‘{print $5}’| cut -d : -f1|sort|uniq -c|sort -n

Find large files on UNIX

find / -size +100000 -type f -ls | sort -n

Create a  30×30 matrix

hexdump -v -e ‘”%u”‘ </dev/urandom|fold -60|head -n 30|sed ‘s/(.{2})/1 /g’

Sort contents of a directory with human readable output

du -hs * | sort -h

Check if a computer is 32 or 64 bits

cat /proc/cpuinfo | grep ” lm ” > /dev/null && echo 64 bits || echo 32 bits

Resume scp of a big file

rsync -a -v –stats -e ssh /home root@<newserver>:/root/

Find out current working directory of a process

pwdx $(pgrep command)

Kill several processes of a user

 ps -ef | grep user | awk ‘{print $2}’ | xargs -i -t kill -9 {}

Leave a Comment