Shared Knowledge

Answers from a crash test dummy

Questioning Reality

Bits and Bytes

Bash Hacks

This is one of the first things I do on my Linux Boxes... What can I say I am a lazy bastard. These make working on Linux much easier and makes Bash even more user friendly and powerful. Most Linux Distro's have a .bashrc file, you can either write them directly into that file or if there is a .bash_aliases file write them into this file since upgrading bash won't break this hack. alias attacks='tail -f -n 2000 /var/log/auth.log' alias attackcount='cat /var/log/auth.log | wc' alias autoremove='apt-get autoremove' alias ban='iptables -I INPUT -j DROP -s' alias clean='apt-get clean;apt-get autoclean' alias firewall='iptlist' alias fix='apt-get -f install' alias halt='sudo /sbin/halt' alias ins='apt-get install $1' ## shortcut for iptables and pass it via sudo# alias ipt='sudo /sbin/iptables' # display all rules # alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers' alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers' alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers' alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers' ## Show hidden files ## alias l.='ls -d .* --color=auto' ## List install packages ## alias list='dpkg -l | grep $1' alias lsbig='ls -gtSrh' alias lsnew='ls -lhat' alias lsold='ls -lhatr' alias lvim="vim -c \"normal '0\"" alias mkdir='mkdir -pv' alias mnt='mount |column -t' alias nocomment='grep -Ev '\''^(#|$)'\''' alias ports='netstat -tulanp' alias poweroff='sudo /sbin/poweroff' alias purge='apt-get purge $1' alias reboot='sudo /sbin/reboot' alias remove='apt-get remove $1' alias research='apt-cache search -f $1' alias rmlock='rm /var/lib/dpkg/lock;rm /var/cache/apt/archives/lock' alias search='apt-cache search $1' alias shutdown='sudo /sbin/shutdown' alias syslog='tail -f -n 1000 /var/log/syslog' alias unban='iptables -D INPUT -j DROP -s' alias update='apt-get update;apt-get dist-upgrade' alias vhostlogs='tail -f -n 20000 /var/log/apache2/other_vhosts_access.log' ## Change the x.x.x.x to an IP you want to filter out from the logs. alias webattack="tail -f -n 20000 /var/log/apache2/other_vhosts_access.log | grep 'POST /administrator' | grep -v X.X.X.X" alias webattackcount='cat /var/log/apache2/other_vhosts_access.log | wc' alias webtraffic='tail -f -n 2000 /var/log/apache2/other_vhosts_access.log | grep -v X.X.X.X'