I have Ubuntu 16.04 installed locally, and it has bash completion for systemctl subcommands by default. But when I start an instance of Ubuntu Server 18.04 on Digital Ocean, there is no bash completion for systemctl subcommands. I'd expect some missing package like systemd-completion, but on my local Ubuntu I have only these packages installed:

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

and completion works. The bash-completion package is installed on both machines.

Also, at /etc/bash_completion.d/ of my local 16.04 machine, I don't see any related systemctl completion files

-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

So, what package should I install to get bash completion for systemctl subcommands? Maybe I should turn something on in bash configs somewhere?


I found this answer by first, finding out which package provides systemctl:

$ dpkg -S $(type -p systemctl)
systemd: /bin/systemctl

Then looking at the contents of the systemd package, I see:

$ dpkg -L systemd
/usr/share/bash-completion/completions/systemctl       <---
  • Thank you, I did not know about /usr/share/bash-completion location. The file you mentioned is already present, and the ip command is also missing bash completion. So looks like it's not a systemd-specific issue, and I should look for some wider bash configuration problem. – Dmitriusan Jun 6 '18 at 16:32
  • So apply my method to the ip command, and don't ask second questions in the comments. – waltinator Jun 7 '18 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.