2

This question already has an answer here:

I can run following command on my Ubuntu 14.04.3 Terminal without any problem:

sudo service network-manager restart
[sudo] password for username: 
network-manager stop/waiting
network-manager start/running, process 5204

If I type sudo service network and then press Tab it is auto completed to sudo service networking.
If I type sudo service network-ma and them press Tab no auto-complete occurs.

My question is if there is a service named network-manager that could be restarted by service command why its name is not auto-completed? and How to solve it?

Update:

ls -l /etc/init.d/network*
-rwxr-xr-x 1 root root 4479 Apr 28  2014 /etc/init.d/networking

marked as duplicate by muru, karel, Eric Carvalho, Mitch Oct 6 '15 at 7:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Could you post the output of ls -l /etc/init.d/network* just to be sure? – terdon Sep 21 '15 at 11:37
  • @terdon The question is updated with the information you asked for. – PHP Learner Sep 22 '15 at 4:46
0

The tab completion for service looks foe files in /etc/init.d. Since there is no network-manager file there, the tab completion fails. A better question is why service network-manager works at all.

According to the service man page:

   The  SCRIPT  parameter  specifies  a  System  V init script, located in
   /etc/init.d/SCRIPT, or the name of an upstart  job  in  /etc/init. 

So, since there is a /etc/init/network-manager.conf file, service can query it, but there is no autocompletion because there is no script of that name in /etc/init.d.

A simple workaround would be to create an empty file called network-manager in /etc/init.d:

sudo touch /etc/init.d/network-manager

Once you've done that, you can tab-complete the name as expected. I tested this in a VM and it seemed to work fine, the service network-manager start|stop|restart|status commands all worked and nothing seemed to be broken. I assume that means that the empty file is ignored and only used for the completion, so it looks like this is safe.

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