CentOS7环境下命令行tab键盘补全

一般情况下CentOS7默认最小化安装,此时如果要命令行tab补全需要安装一个叫做“bash-completion” 的软件包

没有安装bash-completion之前

1 [root@localhost ~]# syste 
2 anaconda-ks.cfg           .bash_logout              .bashrc                   iptables.sh               openscap_data/            .tcshrc                   tools/                    
3 .bash_history             .bash_profile             .cshrc                    nvidia-bug-report.log.gz  .ssh/                     test.sh                   .viminfo                  
4 [root@localhost ~]# systemctl 

安装bash-completion之后

 1 [root@localhost ~]# yum install bash-completion
 2 Loaded plugins: fastestmirror
 3 Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
 4 base                                                                                                                                                                                                             | 3.6 kB  00:00:00     
 5 extras                                                                                                                                                                                                           | 3.4 kB  00:00:00     
 6 updates                                                                                                                                                                                                          | 3.4 kB  00:00:00     
 7 (1/4): base/7/x86_64/group_gz                                                                                                                                                                                    | 166 kB  00:00:00     
 8 (2/4): extras/7/x86_64/primary_db                                                                                                                                                                                | 172 kB  00:00:00     
 9 (3/4): updates/7/x86_64/primary_db                                                                                                                                                                               | 4.2 MB  00:00:02     
10 base/7/x86_64/primary_db       FAILED                                          
11 http://mirrors.shu.edu.cn/centos/7.5.1804/os/x86_64/repodata/03d0a660eb33174331aee3e077e11d4c017412d761b7f2eaa8555e7898e701e0-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.shu.edu.cn:80; Connection refused" ETA 
12 Trying other mirror.
13 (4/4): base/7/x86_64/primary_db                                                                                                                                                                                  | 5.9 MB  00:00:01     
14 Determining fastest mirrors
15  * base: mirrors.cn99.com
16  * extras: mirrors.cn99.com
17  * updates: mirrors.cn99.com
18 Resolving Dependencies
19 --> Running transaction check
20 ---> Package bash-completion.noarch 1:2.1-6.el7 will be installed
21 --> Finished Dependency Resolution
22 
23 Dependencies Resolved
24 
25 ========================================================================================================================================================================================================================================
26  Package                                                       Arch                                                 Version                                                    Repository                                          Size
27 ========================================================================================================================================================================================================================================
28 Installing:
29  bash-completion                                               noarch                                               1:2.1-6.el7                                                base                                                85 k
30 
31 Transaction Summary
32 ========================================================================================================================================================================================================================================
33 Install  1 Package
34 
35 Total download size: 85 k
36 Installed size: 259 k
37 Is this ok [y/d/N]: y
38 Downloading packages:
39 bash-completion-2.1-6.el7.noarch.rpm                                                                                                                                                                             |  85 kB  00:00:00     
40 Running transaction check
41 Running transaction test
42 Transaction test succeeded
43 Running transaction
44   Installing : 1:bash-completion-2.1-6.el7.noarch                                                                                                                                                                                   1/1 
45   Verifying  : 1:bash-completion-2.1-6.el7.noarch                                                                                                                                                                                   1/1 
46 
47 Installed:
48   bash-completion.noarch 1:2.1-6.el7                                                                                                                                                                                                    
49 
50 Complete!
51 [root@localhost ~]# 

再次执行systemctl命令

1 [root@localhost ~]# system
2 systemctl                       systemd-cgls                    systemd-detect-virt             systemd-inhibit                 systemd-nspawn                  systemd-sysv-convert            
3 systemd-analyze                 systemd-cgtop                   systemd-escape                  systemd-loginctl                systemd-path                    systemd-tmpfiles                
4 systemd-ask-password            systemd-coredumpctl             systemd-firstboot               systemd-machine-id-setup        systemd-run                     systemd-tty-ask-password-agent  
5 systemd-cat                     systemd-delta                   systemd-hwdb                    systemd-notify                  systemd-stdio-bridge            
6 [root@localhost ~]# system

显示以system开头的所有命令

原文地址:https://www.cnblogs.com/kindnull/p/9363936.html