It appears lot of my colleagues think they’ll get the name of any service
in Ubuntu system autocompleted by typing
and pressing Tab button. When this does not work (and it does not work a lot) it
creates a lot of confusion and rises lot of questions.
In Ubuntu 14.04, the script that handles completions for
service command is
/usr/share/bash-completion/bash_completion It looks for service names as files in
/etc/init.d, and in the output of
systemctl list-units --full --all
Every package that provides a standard daemon using upstart is required to provide
a symlink in
/etc/init.d by Debian policy. If you have some homegrown upstart services
having only configuration file in
/etc/init you won’t have them in the autocompletion
There are special upstart jobs in
/etc/init that as well do not have a corresponding
/etc/init.d. These are an exception. From Debian Policy:
An exception to this rule is scripts or jobs provided by the init implementation itself; such jobs may be required for an implementation-specific equivalent of the /etc/rcS.d/ scripts and may not have a one-to-one correspondence with the init scripts.
These exceptions do not currently work with bash-completion. However, you can use
reload directly without
service, and autocompletion will work.
sudo start shut correctly autocompletes. But you shouldn’t normally need
to directly call upstart jobs that do not have a corresponding