, ,

Unix – Collection of useful bash aliases

The following aliases have made my unix life 10x easier 🙂

cat ~/.bash_aliases

alias pj='ps -fA|grep java'

# pdf viewer
alias v='qpdfview'

# open browser
alias b='x-www-browser'

# check space left in drives
alias space='df -h'

# open password gorilla
alias pw='password-gorilla'

# Show hidden files
alias l.='ls -d .* --color=auto'

# cd .. aliases
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
alias ........='cd ../../../../../../..'
alias .........='cd ../../../../../../../..'
alias ..........='cd ../../../../../../../../..'
alias .2='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
alias .6='cd ../../../../../..'
alias .7='cd ../../../../../../..'
alias .8='cd ../../../../../../../..'
alias .9='cd ../../../../../../../../..'
alias .10='cd ../../../../../../../../../..'
alias .11='cd ../../../../../../../../../../..'


# history grab
alias hig='history|grep '

alias sz="du -ch $@| egrep '[0-9]+[\.KMGT]\stotal'|awk '{print \$1;}'"

# Grabs the disk usage in the current directory
#alias usage='du -ch | grep total'

#Gets the total disk usage on your machine
alias totalusage='df -hl --total | grep total'

# Shows the individual partition usages without the temporary memory values
alias partusage='df -hlT --exclude-type=tmpfs --exclude-type=devtmpfs'

# Gives you what is using the most space. Both directories and files. Varies on
# current directory
alias most='du -hsx * | sort -rh | head -10'

# shadowbq December 17, 2012 at 2:08 pm
#
#    usage is better written as
alias usage='du -ch 2> /dev/null |tail -1'

alias mkdir='mkdir -pv'

# Create a new set of commands
alias path='echo -e ${PATH//:/\\n}'

# current date now
alias now='date +"%T'
alias nowtime=now
alias nowdate='date +"%d-%m-%Y"'

# Show open ports
#Use netstat command to quickly list all TCP/UDP port on the server:
alias du1='du -h -d 1'
alias ports='netstat -tulanp'

# find files using locate - sudo apt-get install locate
alias lo='locate -i -b --regex'

# ls aliases
alias lf='ls -alF --color=auto'
alias la='ls -al --color=auto'
alias ll='ls -l  --color=auto'
alias l='ls -l  --color=auto'
alias lh='ls -lh  --color=auto'
alias cls='clear'

# ls look into directories above
alias l1='ls -l ..'
alias l2='ls -l ../..'
alias l3='ls -l ../../..'
alias l4='ls -l ../../../..'
alias l='ls -alF --color=auto '
alias ls='ls --color=auto'
alias dir='ls -l --color=auto'

# go to home directory
alias h='cd ~'
alias home='cd ~'

# beep - why or why do you want to make noise ? just fun :)
alias beep='echo -en "\007"'

# delete directories
alias rd='rm -rf'

# create directory
alias md='mkdir -p'

alias o='less'
alias t='tail -f '
# hash
alias rehash='hash -r'
#alias unmount='echo "Error: Try the command: umount" 1>&2; false'
#alias which='type -p'
#alias you='su - -c "/sbin/yast2 online_update"'

# some more ls aliases
# sudo apt-get install -y iotop
alias io='sudo iotop -Pao'

alias upd='sudo apt-get update -y'
alias af='sudo apt-get -f'
alias ar='sudo apt-get -y autoremove'

# apt-get install shortcut
alias i='sudo apt-get install -y'

# apt-get remove shortcut
alias u='sudo apt-get remove -y'

# check if a particular process is running
alias p='ps -ef|egrep -v "grep --color=auto"|egrep --color'

# kill a process
alias k='sudo killall -I -r '

#alias kk='sudo kill -KILL '
#alias pk='sudo pkill -i -f '
#alias rm="mv -t ~/.Trash"
#alias rm="mv -bt ~/.local/share/Trash/files/"
#alias rm='mkdir -p ~/.Trash;mv -t ~/.Trash'
#alias rm='mkdir -p ~/.Trash;mv -n -b -t ~/.Trash'

# use trash command for all deletes - avoids false deletes
# sudo apt-get install -y python-setuptools trash-cli
alias rm='trash-put'

# check blocked network port
alias bp='sudo netstat -lnptu|grep '

References

1. Bash Aliases for Mac, Centos and Linux: http://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html
2. Kill a process: http://www.thegeekstuff.com/2009/12/4-ways-to-kill-a-process-kill-killall-pkill-xkill/