我在本地安装了 Ubuntu 16.04,systemctl
默认情况下它具有子命令的 bash 补全功能。但是当我在 Digital Ocean 上启动 Ubuntu Server 18.04 实例时,没有子systemctl
命令的 bash 补全功能。我预计会缺少一些软件包systemd-completion
,但在我的本地 Ubuntu 上,我只安装了这些软件包:
ii libpam-systemd:amd64 229-4ubuntu21.2 amd64 system and service manager - PAM module
ii libsystemd0:amd64 229-4ubuntu21.2 amd64 systemd utility library
ii libsystemd0:i386 229-4ubuntu21.2 i386 systemd utility library
ii systemd 229-4ubuntu21.2 amd64 system and service manager
ii systemd-shim 9-1bzr4ubuntu1 amd64 shim for systemd
ii systemd-sysv 229-4ubuntu21.2 amd64 system and service manager - SysV links
并完成工作。该bash-completion
包已安装在两台机器上。
另外,在/etc/bash_completion.d/
我的本地 16.04 机器上,我没有看到任何相关的 systemctl 完成文件
-rw-r--r-- 1 root root 408 сер 21 2015 cryptdisks
-rw-r--r-- 1 root root 323 бер 18 2016 desktop-file-validate
-rw-r--r-- 1 root root 2384 сер 13 2010 dkms
-rw-r--r-- 1 root root 439 сер 11 2017 git-prompt
-rw-r--r-- 1 root root 11144 тра 11 2017 grub
-rw-r--r-- 1 root root 736 тра 7 2013 insserv
-rw-r--r-- 1 root root 6596 лют 19 23:06 libreoffice.sh
-rw-r--r-- 1 root root 553 лют 2 2016 openvpn
那么,我应该安装什么软件包才能获得systemctl
子命令的 bash 补全功能?也许我应该在某个 bash 配置中打开某些功能?
答案1
我首先找到了这个答案,找出哪个包提供了systemctl
:
$ dpkg -S $(type -p systemctl)
systemd: /bin/systemctl
然后查看包裹的内容systemd
,我看到:
$ dpkg -L systemd
...<snip>...
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/systemd-run
/usr/share/bash-completion/completions/timedatectl
/usr/share/bash-completion/completions/systemd-analyze
/usr/share/bash-completion/completions/systemd-cgtop
/usr/share/bash-completion/completions/systemd-delta
/usr/share/bash-completion/completions/systemd-path
/usr/share/bash-completion/completions/journalctl
/usr/share/bash-completion/completions/systemd-detect-virt
/usr/share/bash-completion/completions/localectl
/usr/share/bash-completion/completions/networkctl
/usr/share/bash-completion/completions/hostnamectl
/usr/share/bash-completion/completions/bootctl
/usr/share/bash-completion/completions/systemd-cat
/usr/share/bash-completion/completions/systemd-cgls
/usr/share/bash-completion/completions/systemctl <---
/usr/share/bash-completion/completions/busctl
/usr/share/bash-completion/completions/loginctl