【CentOS 7笔记31】,命令补全及别名#

shalow丿ove


命令补全及别名

  • tab键,敲一下,敲两下
  • 参数补全,安装bash-completion
  • alias别名给命令重新起个名字
  • 各用户都有自己配置别名的文件~/.bashrc

命令补全

[root@localhost ~]# yum install -y bash-completion
	Loaded plugins: fastestmirror
	base                                                                        | 3.6 kB  00:00:00     
	epel/x86_64/metalink                                                        | 5.2 kB  00:00:00     
	epel                                                                        | 4.7 kB  00:00:00     
	extras                                                                      | 3.4 kB  00:00:00     
	updates                                                                     | 3.4 kB  00:00:00     
	(1/3): extras/7/x86_64/primary_db                                           | 130 kB  00:00:00     
	(2/3): epel/x86_64/updateinfo                                               | 848 kB  00:00:01     
	(3/3): epel/x86_64/primary_db                                               | 6.1 MB  00:00:10     
	Loading mirror speeds from cached hostfile
	 * epel: mirrors.ustc.edu.cn
	Resolving Dependencies
	--> Running transaction check
	---> Package bash-completion.noarch 1:2.1-6.el7 will be installed
	--> Finished Dependency Resolution

	Dependencies Resolved

	===================================================================================================
	 Package                      Arch                Version                  Repository         Size
	===================================================================================================
	Installing:
	 bash-completion              noarch              1:2.1-6.el7              base               85 k

	Transaction Summary
	===================================================================================================
	Install  1 Package

	Total download size: 85 k
	Installed size: 259 k
	Downloading packages:
	bash-completion-2.1-6.el7.noarch.rpm                                        |  85 kB  00:00:00     
	Running transaction check
	Running transaction test
	Transaction test succeeded
	Running transaction
	  Installing : 1:bash-completion-2.1-6.el7.noarch                                              1/1 
	  Verifying  : 1:bash-completion-2.1-6.el7.noarch                                              1/1 

	Installed:
	  bash-completion.noarch 1:2.1-6.el7                                                               

	Complete!
[root@localhost ~]# systemctl restart network.service     #测试失败
[root@localhost ~]# reboot    #需重启

使用bash-completion包不仅可以补全命令,还可以补全参数

别名

[root@localhost ~]# systemctl restart network.service     #重新测试
[root@localhost ~]# alias restart='systemctl restart network.service'
[root@localhost ~]# restart
[root@localhost ~]# 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 restart='systemctl restart network.service'
	alias rm='rm -i'
	alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

各用户都有自己配置别名的文件~/.bashrc

[root@localhost ~]# vi .bashrc
	# .bashrc

	# User specific aliases and functions

	alias rm='rm -i'
	alias cp='cp -i'
	alias mv='mv -i'

	# Source global definitions
	if [ -f /etc/bashrc ]; then
			. /etc/bashrc
	fi

其他alias配置文件

[root@localhost ~]# cd /etc/profile.d
[root@localhost profile.d]# ls
	256term.csh         colorgrep.csh  colorls.sh  less.csh  vim.sh
	256term.sh          colorgrep.sh   lang.csh    less.sh   which2.csh
	bash_completion.sh  colorls.csh    lang.sh     vim.csh   which2.sh

转载于:https://my.oschina.net/u/3892756/blog/3056521

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值