命令補全及別名目錄概要
- tab鍵,敲一下,敲兩下
- 參數補全,安裝 bash-completion
- alias別名給命令從新起個名字
- 各用戶都有本身配置別名的文件 ~/.bashrc
- ls /etc/profile.d/
- 自定義的alias 放到 ~/.bashrc
命令補全
alias別名
[root@hf-01 ~]# systemctl restart network.service //重啓網絡服務
[root@hf-01 ~]# alias restartnet='systemctl restart network.service'
[root@hf-01 ~]# restartnet //設置別名後,重啓網絡服務
[root@hf-01 ~]#
- 取消別名unalias
- 在取消別名後,在輸入別名,就會提示未找到命令
[root@hf-01 profile.d]# unalias restartnet
[root@hf-01 profile.d]# restartnet
-bash: restartnet: 未找到命令
[root@hf-01 profile.d]#
-
- 直接輸入alias 會看到系統中全部的別名(包括本身自定義的alias)
[root@hf-01 ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias restarnet='systemctl restart network.service'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@hf-01 ~]#
-
- alias存放位置
- 第一個是存放在用戶家目錄下的 .bashrc 文件中
- 第二個是存放在 /etc/profile.d 目錄下的 colorls.sh 和 colorgrep.sh 腳本中定義的