I'm running OpenSUSE 12.3 (and have seen the behavior since 11), and have found that I can't call Superuser programs (e.g. shutdown, reboot) without using the full path. For me, many of these executables live in /sbin, so instead of using sudo reboot, I have to call sudo /sbin/reboot. Thankfully, when using sudo OpenSUSE's shell (bash) will expand these paths when I press the Tab key, so sudo rebo[Tab] will result in sudo /sbin/reboot.

OpenSUSE provides a package by the name of bash-completion which expands the auto-complete functionality of bash to include all sorts of other contexts (e.g. gsettings). Unfortunately, by default, this package does not expand the Superuser executables to their full paths, but just expands the executable name, so sudo rebo[Tab] will result in sudo reboot, which will lead to a sudo: reboot: command not found error.

How do I install/run bash-completion yet ensure the autocomplete for Superuser executables expands to the full path?

  • 4
    That's a problem with your sudo configuration. Normally sudo does add the sbin directories to the search path. – Gilles Aug 27 '13 at 23:20
  • I think the SUSE developers might disagree that this constitutes a problem, since the expansion to a full path clearly indicates that the developers have done this by design. I am just asking the question whether bash-completion can mimic this behavior. – palswim Aug 28 '13 at 17:44

Why not just add /sbin to PATH var?: export PATH=$PATH:/sbin


Expanding @Gilles's comment to an answer:

This question asked about bash-completion expanding /sbin executables to their full paths on Tab, but I have satisfied my requirements by adding the Superuser directories (e.g. /sbin, /usr/sbin, etc.) to the sudo search path.

To do this, I had to add the secure_path variable to the Sudoers file (edit with visudo), something like the following line:

Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

If someone provides a solution to actually expand the path of these executables, I would consider that the true answer to the question, but again, this solution satisfies my requirements.

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.