命令补全
Tab键,敲一下补全指令、路径或者文件名;连续按两次Tab键,系统会把以当前字符串开头的所有匹配项都列出来。
CentOS 6及其之前版本,只支持命令本身补全,不支持命令的参数补全。CentOS 7中,支持命令的参数补全,默认不支持,需要安装bash-completion包。
[root@centos-01 ~]# yum install -y bash-completion
安装完后,需要重启系统才能生效。
[root@centos-01 ~]# reboot
[root@centos-01 ~]# rpm -qa bash-completionbash-completion-2.1-6.el7.noarch
alias别名
通过alias
命令,可以把一个常用的并且很长的指令别名为一个简洁易记的指令。不想用了,可以用unalias
解除别名功能。直接敲alias
会看到目前系统预设的alias。
[root@centos-01 ~]# aliasalias 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 rm='rm -i'alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
alias语法:alias [命令别名]=[‘具体的命令’]
例如
alias restartnet='systemctl restart network.service'
。使用“unalias 命令别名
”就可以把设置的别名给解除了。
用户家目录下面的.bashrc
文件,是各用户自己配置别名的文件。
[root@centos-01 ~]# cat .bashrc # .bashrc# User specific aliases and functionsalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrcfi
还有一部分配置别名的文件,在/etc/profile.d
目录下。
[root@centos-01 ~]# ls /etc/profile.d/256term.csh bash_completion.sh colorgrep.sh colorls.sh lang.sh less.sh vim.sh which2.sh256term.sh colorgrep.csh colorls.csh lang.csh less.csh vim.csh which2.csh