sh bash别名

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh bash别名相关的知识,希望对你有一定的参考价值。

## get rid of command not found ##
alias cd..='cd ..'
 
## a quick way to get out of current directory ##
alias ..='cd ..'
alias ...='cd ../../../'
alias ....='cd ../../../../'
alias .....='cd ../../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../..'

## Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'

## Calc
alias bc='bc -l'

## SHA1 digest
alias sha1='openssl sha1'

## Create parent if missing
alias mkdir='mkdir -pv'

## diff -> colordiff (req. colordiff)
alias diff='colordiff'

## User-friendly mount output
alias mount='mount |column -t'

## handy short cuts #
alias h='history'
alias j='jobs -l'

alias path='echo -e ${PATH//:/\\n}'
alias now='date +"%T"'
alias nowtime=now
alias nowdate='date +"%d-%m-%Y"'

## Stop after sending count ECHO_REQUEST packets #
alias ping='ping -c 5'
## Do not wait interval 1 second, go fast #
alias fastping='ping -c 100 -s.2'

## Show open ports
alias ports='netstat -tulanp'

## become root 
alias root='sudo -i'
alias su='sudo -i'

## reboot / halt / poweroff
alias reboot='sudo /sbin/reboot'
alias poweroff='sudo /sbin/poweroff'
alias halt='sudo /sbin/halt'
alias shutdown='sudo /sbin/shutdown'

## pass options to free ##
alias meminfo='free -m -l -t'
 
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
 
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
 
## Get server cpu info ##
alias cpuinfo='lscpu'
 
## older system use /proc/cpuinfo ##
##alias cpuinfo='less /proc/cpuinfo' ##
 
## get GPU ram on desktop / laptop##
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'

## this one saved by butt so many times ##
alias wget='wget -c'

## set some other defaults ##
alias df='df -H'
alias du='du -ch'
 
# top is atop, just like vi is vim
alias top='atop'
 
## nfsrestart  - must be root  ##
## refresh nfs mount / cache etc for Apache ##
alias nfsrestart='sync && sleep 2 && /etc/init.d/httpd stop && umount netapp2:/exports/http && sleep 2 && mount -o rw,sync,rsize=32768,wsize=32768,intr,hard,proto=tcp,fsc natapp2:/exports /http/var/www/html &&  /etc/init.d/httpd start'
 
## Memcached server status  ##
alias mcdstats='/usr/bin/memcached-tool 10.10.27.11:11211 stats'
alias mcdshow='/usr/bin/memcached-tool 10.10.27.11:11211 display'
 
## quickly flush out memcached server ##
alias flushmcd='echo "flush_all" | nc 10.10.27.11 11211'
 
## Remove assets quickly from Akamai / Amazon cdn ##
alias cdndel='/home/scripts/admin/cdn/purge_cdn_cache --profile akamai'
alias amzcdndel='/home/scripts/admin/cdn/purge_cdn_cache --profile amazon'
 
## supply list of urls via file or stdin
alias cdnmdel='/home/scripts/admin/cdn/purge_cdn_cache --profile akamai --stdin'
alias amzcdnmdel='/home/scripts/admin/cdn/purge_cdn_cache --profile amazon --stdin'

# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
    alias reboot='sudo reboot'
    alias update='sudo apt-get upgrade'
fi

## List files in order of ascending size (the second form takes a file-pattern argument):
function lsdu() { ls -l $* | sort --key=5.1 -n; };
function lsduf() { ls -l | egrep $* | sort --key=5.1 -n; };

## List the 10 most recently edited/changed files (m = more, a poor-man’s more)
alias lsm='ls -lt | head -n 10'

## List the tasks using the most CPU time
alias hogs='ps uxga | sort --key=4.1 -n'

## Count the number of files in current dir
alias lsc='ls -l | wc -l'
 
## Sort directories by sizes
alias dush='du -h --max-depth=1 | sort -h'
 
## Can't see all the files in one page ?
alias lsless='ls | less'
 
## Make a video capture of the desktop
alias capturedesktop='avconv -f x11grab -r 25 -s 1900x1000 -i :0.0+0,24 -vcodec libx264  -threads 0'
 
## Capture desktop, with sound
alias capturedesktop_withsound='avconv -f x11grab -r 25 -s 1900x1000 -i :0.0+0,24 -vcodec libx264  -threads 0 -f alsa -i hw:0 '
 
## Only print actual code/configuration
alias removeblanks="egrep -v '(^[[:space:]]*#|^$|^[[:space:]]*//)'"
 
## Useful when you want to scp to your own machine from a remote server
alias myip='ifdata -pa eth1'

## Readable memory info
alias minfo='egrep "Mem|Cache|Swap" /proc/meminfo'

以上是关于sh bash别名的主要内容,如果未能解决你的问题,请参考以下文章

sh bash别名

sh BASH常用别名及设置

sh Bash别名

sh git的Bash别名

sh Bash别名

sh 有用的bash别名或命令