16

I'm on 12.04 and I'm trying to find a way to enable Bash completion in root user.

Any ideas on how to do that?

9
  • Possible duplicate? askubuntu.com/questions/33440/…
    – lumbric
    May 27, 2012 at 18:46
  • While trying to type what, is your bash completion not working? Or is it not working at all? May 27, 2012 at 18:46
  • It's Not Working While Trying To Type In ROOT, In Ordinary users It Works Just Fine, For Example : root# apt-get install gua[tab][tab] it Must Show Sth Like Guake, But It Wont, Also For Other Things, While It's Showing The Same Thing While I'm Using An Ordinary User, And Using An Extra "Sudo" Before That Command... May 27, 2012 at 19:11
  • 1
    @T0MXeOnLuCiFeR can you add the output of sudo cat /root/.bashrc?
    – lumbric
    May 27, 2012 at 19:27
  • 4
    @T0MXeOnLuCiFeR Do you mind not writing "Like This Phrase?", makes things harder to read and makes not sense at all to use. May 27, 2012 at 22:47

2 Answers 2

30

Bash completion can be enabled in the file .bashrc as explained in this Q&A. In your case it seems to be correct in your user's .bashrc, but not in your root's .bashrc. The latter file is located in /root/.bashrc. Open this file with your favorite text editor as root (e.g. by running sudo gedit /root/.bashrc) and remove the # in the beginning of the last three lines:

You have to change the lines 98-100 from

#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#    . /etc/bash_completion
#fi

...to:

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi

Then close your terminals and reopen them.

5
  • tnx, i'm still having problem, see i mean sub commands like when u have typed apt-get now you r going to type "install" u type the first 3 words then you hit tab in normal user it works in root user it doesn't.... what should i do right now...? May 29, 2012 at 11:35
  • I DID, what u told me.... yet it's not working, do you have any other idea? May 29, 2012 at 12:37
  • @T0MXeOnLuCiFeR I'm quite sure that this is the source of your problem. Did you cat again to see if you actually changed the file as I suggested? Did you close and reopen all terminals? If not, try to run . /etc/bash_completion manually (note that there is a .!).
    – lumbric
    May 31, 2012 at 16:56
  • Yes Man I Did It ... Tnx Anyway It Got Better, But Not What I Thought...I Check For More Details. Jun 2, 2012 at 17:01
  • @T0MXeOnLuCiFeR did you try to run . /etc/bash_completion manually?
    – lumbric
    Jun 2, 2012 at 18:18
1

I successfully enabled "bash completion" in Ubuntu 12.04 LTS by editing the file "bash.bash.rc" in "etc".

I just removed the "#" in lines 32-34 and bash completion for "sudo" works fine now.

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.