Dmi*_*san 3 command-line bash auto-completion systemd
我本地安装了 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\nii libsystemd0:amd64 229-4ubuntu21.2 amd64 systemd utility library\nii libsystemd0:i386 229-4ubuntu21.2 i386 systemd utility library\nii systemd 229-4ubuntu21.2 amd64 system and service manager\nii systemd-shim 9-1bzr4ubuntu1 amd64 shim for systemd\nii systemd-sysv 229-4ubuntu21.2 amd64 system and service manager - SysV links\n
Run Code Online (Sandbox Code Playgroud)\n\n和竣工工程。这bash-completion
软件包已安装在两台机器上。
另外,在/etc/bash_completion.d/
我的本地 16.04 机器上,我没有看到任何相关的 systemctl 完成文件
-rw-r--r-- 1 root root 408 \xd1\x81\xd0\xb5\xd1\x80 21 2015 cryptdisks\n-rw-r--r-- 1 root root 323 \xd0\xb1\xd0\xb5\xd1\x80 18 2016 desktop-file-validate\n-rw-r--r-- 1 root root 2384 \xd1\x81\xd0\xb5\xd1\x80 13 2010 dkms\n-rw-r--r-- 1 root root 439 \xd1\x81\xd0\xb5\xd1\x80 11 2017 git-prompt\n-rw-r--r-- 1 root root 11144 \xd1\x82\xd1\x80\xd0\xb0 11 2017 grub\n-rw-r--r-- 1 root root 736 \xd1\x82\xd1\x80\xd0\xb0 7 2013 insserv\n-rw-r--r-- 1 root root 6596 \xd0\xbb\xd1\x8e\xd1\x82 19 23:06 libreoffice.sh\n-rw-r--r-- 1 root root 553 \xd0\xbb\xd1\x8e\xd1\x82 2 2016 openvpn\n
Run Code Online (Sandbox Code Playgroud)\n\n那么,我应该安装什么包才能完成systemctl
子命令的 bash?\n也许我应该在 bash 配置中的某处打开某些功能?
我首先找到了这个答案,找出哪个包提供了systemctl
:
$ dpkg -S $(type -p systemctl)
systemd: /bin/systemctl
Run Code Online (Sandbox Code Playgroud)
然后查看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
Run Code Online (Sandbox Code Playgroud)