命令补全及别名目录概要
- 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 脚本中定义的