20

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!!?".

0

6 Answers 6

33

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 of systemctl list-units --full --all.

But installing the vsftpd package doesn't put any files in /etc/init.d, because it has been systemd-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 a systemctl 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.

1
  • For those who find this answer: Completion finding services (and time to find/parse) has always been a problem under 14.xx, 16.xx 18.xx : Good example: sudo systemctl (status or stop)lightd (TAB/Double TAB) (Meaning complete 'lightdm.service' assuming you have it installed - active/running or not) This svc is both in units output and /etc/init.d on my machine. I have found same issue on other services as well. There is also a bug(?) that makes it take a long time on completions. Seen it sit 10+ secs before beeping at me/not found. github.com/systemd/systemd/issues/7185
    – B. Shea
    Aug 31, 2018 at 17:23
11

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.

5
  • I used:tab + tab does not work for vsftpd. You and Rinzwind's suggestion is work for example su + tab + tab. But for vsftpd does not work. May 27, 2014 at 19:27
  • you can test that first install small program vsftpd by sudo apt-get install vsftpd and then try tab + tab May 27, 2014 at 19:31
  • 2
    tab+tab does not work in case of parameters. In sudo service vsftpd status, the vsftpd is a parameter of service, and therefore will not be found with a double tab. The OP is correct at this point.
    – Jos
    May 27, 2014 at 19:50
  • 2
    @Jos But other services like apache2 and networking autocomplete. How are they different?
    – Dan
    May 27, 2014 at 19:56
  • @dan08 I stand corrected. Moreover, sudo service networking tab tab will offer force-reload reload restart start stop. So it works even better than I thought.
    – Jos
    May 27, 2014 at 20:00
6

vsftpd has probably more than 1 option. tab twice to view the possibilities.

Example: li with tabtab shows:

libnetcfg          line               lintian-info       lispmtopgm
libreoffice        linguist           linux32            listres
lightdm            link               linux64            
lightdm-session    lintian            linux-boot-prober  
0
4

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 have su and press tab/tab it gives you all users, yeah. See here

0

I've found that systemctl list-units --full --all does not list disabled services, so autocompletion doesn't

# check if enabled
systemctl is-enabled <service_name>
# enable
systemctl enable <service_name>
0

The 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

systemctl status <service_name>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .