在linux中alias用于显示当前用户bash中缩定义的所有命令别名。
[root@localhost ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
建立命令别名:
我们把ls -l 建立成别名,以后只用打test 就是用ls -l 具体命令:
先打ls -l显示:
[root@localhost ~]# ls -l
total 64
-rw------- 1 root root 893 Jun 20 04:01 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Jun 27 22:04 Desktop
-rw-r--r-- 1 root root 26296 Jun 20 04:01 install.log
-rw-r--r-- 1 root root 3488 Jun 20 04:00 install.log.syslog
drwxr-xr-x 2 root root 4096 Jul 12 19:57 test
然后用命令定义别名:
[root@localhost ~]# alias test='ls -l'
完成后在命令行中大test显示:
[root@localhost ~]# test
total 64
-rw------- 1 root root 893 Jun 20 04:01 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Jun 27 22:04 Desktop
-rw-r--r-- 1 root root 26296 Jun 20 04:01 install.log
-rw-r--r-- 1 root root 3488 Jun 20 04:00 install.log.syslog
drwxr-xr-x 2 root root 4096 Jul 12 19:57 test
转载于:https://blog.51cto.com/myfeier/609975