alias 用于設(shè)置命令別名
// 錯(cuò)誤實(shí)例
shuai@ubuntu:~$ alias myls = "ls -l" // 不能有空格
bash: alias: myls: not found
bash: alias: =: not found
bash: alias: ls -l: not found
shuai@ubuntu:~$ alias myls="ls -l" // 正確創(chuàng)建別名
shuai@ubuntu:~$ alias // 顯示系統(tǒng)所有別名
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'
alias myls='ls -l' // 可以看到自己的別名已經(jīng)加進(jìn)來(lái)了
shuai@ubuntu:~$ myls // 調(diào)用自己的別名指令
total 60
-rw-r--r-- 1 shuai shuai 33 Apr 26 22:20 a.txt
-rw-r--r-- 1 shuai shuai 38 Apr 26 21:17 b.txt
-rw-r--r-- 1 shuai shuai 11 Apr 26 21:13 c.txt
drwxr-xr-x 2 shuai shuai 4096 Apr 26 15:27 Desktop
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Documents
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Downloads
-rw-r--r-- 1 shuai shuai 8980 Apr 19 17:37 examples.desktop
-rw-r--r-- 1 shuai shuai 26 Apr 26 21:48 manage.py
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Music
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Pictures
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Public
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Templates
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Videos
shuai@ubuntu:~$ ls -l // 別名指令對(duì)應(yīng)的指令
total 60
-rw-r--r-- 1 shuai shuai 33 Apr 26 22:20 a.txt
-rw-r--r-- 1 shuai shuai 38 Apr 26 21:17 b.txt
-rw-r--r-- 1 shuai shuai 11 Apr 26 21:13 c.txt
drwxr-xr-x 2 shuai shuai 4096 Apr 26 15:27 Desktop
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Documents
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Downloads
-rw-r--r-- 1 shuai shuai 8980 Apr 19 17:37 examples.desktop
-rw-r--r-- 1 shuai shuai 26 Apr 26 21:48 manage.py
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Music
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Pictures
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Public
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Templates
drwxr-xr-x 2 shuai shuai 4096 Apr 19 18:03 Videos
shuai@ubuntu:~$ unalias myls // 刪除別名
shuai@ubuntu:~$ 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'