别名

1.查看别名

alias

xiaohuang@xiaohuang-virtual-machine:~$ alias
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

  

2.临时别名

alias l="ls -al"

xiaohuang@xiaohuang-virtual-machine:~/桌面$ alias l="ls -al"
xiaohuang@xiaohuang-virtual-machine:~/桌面$ ls -al
总用量 358028
drwxr-xr-x  3 xiaohuang xiaohuang      4096 8月  31 19:08 .
drwxr-xr-x 28 xiaohuang xiaohuang      4096 9月   8 16:32 ..
drwxrwxr-x 11 root      root           4096 8月  30 15:31 pycharm-2018.2.2
-rwxr-xr-x  1 xiaohuang xiaohuang       248 8月  31 19:08 pycharm.desktop
-rwx--x--x  1 root      root          12288 8月  31 19:05 .pycharm.desktop.swp
-rw-r--r--  1 xiaohuang xiaohuang 343667267 8月  26 19:28 pycharm-professional-2018.2.2.tar.gz
-rw-rw-r--  1 xiaohuang xiaohuang  22915896 4月  19 09:11 sogoupinyin_2.2.0.0108_amd64.deb?st=93MRCONlxfWCyBCObV-Fvg
-rw-r--r--  1 xiaohuang xiaohuang      2995 8月  30 16:05 新建文本文档.txt
xiaohuang@xiaohuang-virtual-machine:~/桌面$ l
总用量 358028
drwxr-xr-x  3 xiaohuang xiaohuang      4096 8月  31 19:08 .
drwxr-xr-x 28 xiaohuang xiaohuang      4096 9月   8 16:32 ..
drwxrwxr-x 11 root      root           4096 8月  30 15:31 pycharm-2018.2.2
-rwxr-xr-x  1 xiaohuang xiaohuang       248 8月  31 19:08 pycharm.desktop
-rwx--x--x  1 root      root          12288 8月  31 19:05 .pycharm.desktop.swp
-rw-r--r--  1 xiaohuang xiaohuang 343667267 8月  26 19:28 pycharm-professional-2018.2.2.tar.gz
-rw-rw-r--  1 xiaohuang xiaohuang  22915896 4月  19 09:11 sogoupinyin_2.2.0.0108_amd64.deb?st=93MRCONlxfWCyBCObV-Fvg
-rw-r--r--  1 xiaohuang xiaohuang      2995 8月  30 16:05 新建文本文档.txt

  

3. 永久别名

vim ~/.bashrc (修改/.bashrc)
alias l='ls -al' (alias 别名="原命令")
source ~/.bashrc (让配置文件立即生效)

猜你喜欢

转载自www.cnblogs.com/huanggaoyu/p/10056243.html