Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have just came across something that is really bothering me. Autocompletion on ubuntu works like a charm but when I login as root, e.g. su I get tab autocompletion only sometimes.

Why does it work like that? Can one change that?

share|improve this question
Are you actually logging in as root, or using sudo su? – Marty Fried Feb 12 '12 at 19:08
@MartyFried Yes I am diong sudo su. What is the difference? – Patryk Feb 12 '12 at 19:19
It seems to work for me, can you provide us with a specific instance of when it does not work, something that we can replicate. – Ubuntu_kwr Feb 12 '12 at 20:20
@lordmonkey: Maybe none, I'm not really sure. I think su or sudo su by itself is a little different in some way that I don't remember, so I wanted to make sure that I could check this under the same conditions. It seems like it works, but you said "sometimes", so I can only suggest you double-check and try to make it reproducible, or just make sure there's not something else happening that is fooling you - ie, user error - hey, it happens to everyone! :) – Marty Fried Feb 12 '12 at 20:48

2 Answers

up vote 6 down vote accepted

Check your /root/.bashrc file for these lines

if [ -f /etc/bash_completion ]; then
  . /etc/bash_completion
fi

If they do not exist add them to the end of the file using your favorite text editor.

share|improve this answer
Mine .bashrc contained the mentioned lines but they were commented out; uncommented the lines and sourced the new .bashrc ; things look pretty good now . – Ankit Jul 10 '12 at 2:30

You haven't mentioned which Ubuntu version you use.

  • Check if you have the bash-completion package installed:

    sudo apt-get install bash-completion
    
  • Mine works if I login using: sudo -i

share|improve this answer
What's the point of removing root's .bashrc? – geirha Jun 27 '12 at 11:09
I think it will regenerate the default .bashrc upon next logout/login. Or perhaps it could contain some kind of "deactivation" for autocompletion (don't know if it's possible). I can't remember the actual reason I wrote it down though. – medigeek Jun 27 '12 at 13:23
1  
No, a new .bashrc will not be created, and /etc/bash_completion will not be sourced, only bash's default completion will be available. – geirha Jun 27 '12 at 13:35
OK, edited and removed. Thank you for your input! Though I wonder if ~/.bashrc can "unsource" a file or if disable-completion is still available: superuser.com/questions/37148/… – medigeek Jun 28 '12 at 4:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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