Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Possible duplicate?… – lumbric May 27 '12 at 18:46
While trying to type what, is your bash completion not working? Or is it not working at all? – harisibrahimkv May 27 '12 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... – T0M XeOn LuCiFeR May 27 '12 at 19:11
@T0MXeOnLuCiFeR can you add the output of sudo cat /root/.bashrc? – lumbric May 27 '12 at 19:27
@T0MXeOnLuCiFeR Do you mind not writing "Like This Phrase?", makes things harder to read and makes not sense at all to use. – Bruno Pereira May 27 '12 at 22:47
up vote 14 down vote accepted

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

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

Then close your terminals and reopen them.

share|improve this answer
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...? – T0M XeOn LuCiFeR May 29 '12 at 11:35
I DID, what u told me.... yet it's not working, do you have any other idea? – T0M XeOn LuCiFeR May 29 '12 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 '12 at 16:56
Yes Man I Did It ... Tnx Anyway It Got Better, But Not What I Thought...I Check For More Details. – T0M XeOn LuCiFeR Jun 2 '12 at 17:01
@T0MXeOnLuCiFeR did you try to run . /etc/bash_completion manually? – lumbric Jun 2 '12 at 18:18

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.

share|improve this answer

Your Answer


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.