I have a VPS from Linode. I deployed Ubuntu 10.04 server. I added a user and put it sudoers file. when I write as a user

apti <TAB>

it comletes with tab to

aptitude <TAB>

but when I continue to

aptitude upd <TAB>

it didnt complete but on my desktop it works great. Even worse if I try same command with sudo

sudo apti <TAB>

does not work I checked .basrc, .profile/.bashrc and /etc/bash.basrc files and none of them were commented out so what is wrong. By the way when I root it works

mine ~/bashrc

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi
link|improve this question

67% accept rate
feedback

4 Answers

up vote 5 down vote accepted

When I got my Linode (Jaunty) I had to install bash-completion. Give that a go.

link|improve this answer
yep, this will enable the bash completion you're used to. back in my day... nevermind... – cpbills May 13 '10 at 16:12
bash-completion is already installed. Still completion does not work for sudo commands and without sudo only works for first argument – Gok Demir May 13 '10 at 16:26
1  
try apt-get remove --purge bash-completion and then apt-get update and apt-get install bash-completion, then log out, and back in, without more information, i.e. what your bash config files look like, it's hard to diagnose. – cpbills May 13 '10 at 16:42
although bash-completion is installed. purge and reinstall solved the problem. – Gok Demir May 14 '10 at 14:50
feedback

You should have something like this in your ~/.bashrc:

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

What do you mean "they are all commented out"? It's possible that something you need is commented out and that's causing your problem.

link|improve this answer
I mean only related parts exactly as your post – Gok Demir May 13 '10 at 17:01
Denis I added mine bashrc – Gok Demir May 13 '10 at 17:04
@gokdemir: "Commented out" means "disabled" and would have a "#" as the first non-whitespace character on the line. Also, in your question, it appears that there is a space before the <TAB>. Are you actually typing that space before you press <TAB>? If you issue the command shopt progcomp does it say "on"? – Dennis Williamson May 13 '10 at 18:48
shame on me. I actually meant none of were commented out. Shopt progcomp says "on". – Gok Demir May 14 '10 at 8:18
feedback

You may also want to add the line "complete -cf sudo" to your ~/.bashrc file. This will allow bash to search for commands after sudo rather than searching for files in the current directory. I do the same with a lot of other commands too such as man and which.

link|improve this answer
feedback

Check you don't have commented these lines out

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

once in your ~/.bashrc file (probably ok) and once in the /root/.bashrc file where it is from unknown reasons commented out.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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