Sometimes, when I type a command on the terminal, the terminal's autocomplete does not work, even if my command is not wrong.
For example, take look to this: sudo service vsftpd status
sudo and service do not have any problem. I mean, when you type sud +tab terminal suggest you sudo or I type servi + tab terminal complete that to service. But for vsftpd I do not get any suggestion. Is there a way to say, "terminal, please tell me any suggestion!!?".
The degree to which auto-completion works is a function of how well the shell scripts in the
bash-completion
package work.In Ubuntu 14.04, the script that handles completions for
service
is in/usr/share/bash-completion/bash_completion
. It looks for service names as files in/etc/rc.d/init.d
and/etc/init.d
, and in the output ofsystemctl list-units --full --all
.But installing the
vsftpd
package doesn't put any files in/etc/init.d
, because it has beensystemd
-ified; it puts a config file in/etc/systemd/system/vsftpd.service
.systemctl list-units
would find that file if not for the fact that Ubuntu, at the present time, doesn't include asystemctl
command.So, at the moment, you won't get auto-completions for
service vsftpd
, but you will for most other services, since their config files are in/etc/init.d
.When there are multiple possible suggestions, tab will not produce any suggestion. Using tab tab (double tab) will produce a list of all possible suggestions.
vsftpd has probably more than 1 option. tab twice to view the possibilities.
Example:
li
with tabtab shows:You can build your own!
E.g.: put
complete -f -r -c su -d 'Username' -a '(cat /etc/passwd|cut -d : -f 1)'
into bash than if you havesu
and press tab/tab it gives you all users, yeah. See hereI've found that
systemctl list-units --full --all
does not list disabled services, so autocompletion doesn'tThe services command relies on "systemctl list-units --full --all", and does not list services that are unable to start (or disabled as above), to confirm if you experiencing this issue you can run