bash-completion能提示命令、提示命令参数等,在CentOS7中,很多日常管理的命令格式较长如nmcli、ip、firewall-cmd、systemctl等,借助bash-completion可以快速、友好地学习新命令的使用。
最小化安装系统的时候默认不安装,由于软件在epel库中,安装时先安装epel-release.注意,安装完成后在新shell里生效,所以需要重连或创建新bash。
yum install epel-release -y yum install bash-completion -y
如下,已经安装好的软件信息:
[root@localhost ~]# rpm -qi bash-completion Name : bash-completion Relocations: (not relocatable) Version : 1.3 Vendor: Fedora Project Release : 7.el6 Build Date: 2013年04月02日 星期二 23时00分20秒 Install Date: 2017年06月21日 星期三 09时46分44秒 Build Host: buildvm-02.phx2.fedoraproject.org Group : System Environment/Shells Source RPM: bash-completion-1.3-7.el6.src.rpm Size : 590294 License: GPLv2+ Signature : RSA/8, 2013年04月03日 星期三 07时44分10秒, Key ID 3b49df2a0608b895 Packager : Fedora Project URL : http://bash-completion.alioth.debian.org/ Summary : Programmable completion for Bash Description : bash-completion is a collection of shell functions that take advantage of the programmable completion feature of bash.
使用TAB键补全命令、补全参数示范如下,CentOS7系统中命令的可读性强,参数和选项使用起来更友好:
#bash-completion功能示范,TAB键补齐常用命令参数选项 [root@localhost ~]# system systemctl systemd-inhibit systemd-analyze systemd-loginctl systemd-ask-password systemd-machine-id-setup systemd-cat systemd-notify systemd-cgls systemd-nspawn systemd-cgtop systemd-path systemd-coredumpctl systemd-run systemd-delta systemd-stdio-bridge systemd-detect-virt systemd-sysv-convert systemd-escape systemd-tmpfiles systemd-firstboot systemd-tty-ask-password-agent systemd-hwdb [root@localhost ~]# systemctl add-requires hybrid-sleep reload-or-restart add-wants is-active reload-or-try-restart cancel is-enabled rescue cat is-failed reset-failed condreload isolate restart condrestart is-system-running set-default condstop kexec set-environment daemon-reexec kill set-property daemon-reload link show default list-dependencies show-environment delete list-jobs snapshot disable list-sockets start edit list-timers status emergency list-unit-files stop enable list-units suspend exit mask switch-root force-reload poweroff try-restart get-default preset unmask halt reboot unset-environment help reenable hibernate reload [root@localhost ~]# nmcli agent device help networking connection general monitor radio [root@localhost ~]# nmcli connection add delete edit help load monitor show clone down export import modify reload up [root@localhost ~]# nmcli connection edit con-name ens192 id type ens160 help path uuid [root@localhost ~]# nmcli connection add autoconnect ipv4.dns-priority con-name ipv4.dns-search connection.autoconnect ipv4.gateway connection.autoconnect-priority ipv4.ignore-auto-dns connection.autoconnect-slaves ipv4.ignore-auto-routes connection.gateway-ping-timeout ipv4.may-fail connection.id ipv4.method connection.interface-name ipv4.never-default connection.lldp ipv4.route-metric connection.master ipv4.routes connection.metered ipv6.addresses connection.permissions ipv6.addr-gen-mode connection.read-only ipv6.dhcp-hostname connection.secondaries ipv6.dhcp-send-hostname connection.slave-type ipv6.dns connection.stable-id ipv6.dns-options connection.timestamp ipv6.dns-priority connection.type ipv6.dns-search connection.uuid ipv6.gateway connection.zone ipv6.ignore-auto-dns help ipv6.ignore-auto-routes ifname ipv6.ip6-privacy ipv4.addresses ipv6.may-fail ipv4.dad-timeout ipv6.method ipv4.dhcp-client-id ipv6.never-default ipv4.dhcp-fqdn ipv6.route-metric ipv4.dhcp-hostname ipv6.routes --More--^C [root@localhost ~]# firewall-cmd -- --add-forward-port= --add-icmp-block= --add-icmp-block-inversion --add-interface= --add-lockdown-whitelist-command= --add-lockdown-whitelist-context= --add-lockdown-whitelist-uid= --add-lockdown-whitelist-user= --add-masquerade --add-port= --add-protocol= --add-rich-rule= --add-service= --add-source= --add-source-port= --change-interface= --change-source= --change-zone= --complete-reload --direct --get-active-zones --get-default-zone --get-icmptypes --get-ipset-types --get-log-denied --get-services --get-zone-of-interface= --get-zones --help --info-icmptype --info-ipset --info-service --info-zone --More-- [root@localhost ~]# firewall-cmd --
转载于:https://blog.51cto.com/jonathan/1947412