View Full Version : [SOLVED] JeOS 8.04 and sudo tab completion

March 3rd, 2010, 08:05 AM
Can anyone tell me how to get tab completion working with sudo in JeOS (Ubuntu Hardy) 8.04? Assuming I have the command '/usr/bin/svnadmin'. As a normal user I can type:

svnad + TAB...and it auto-completes as 'svnadmin'. If I type:

sudo svnad + TAB...nothing happens. My 'echo $SHELL' is '/bin/bash'. I tried enabling the following in '/etc/bash.bashrc':

if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi...but it had no effect (I even tried a reboot to be sure). It's worth noting that tab completion works as I'd expect if I use absolute paths. For example:

sudo /usr/bin/svnad + TAB...auto-completes as I'd expect. I think I once read that there's some kind of configuration variable for sudo that causes it to use a 'more secure' path rather than the current path in the user's environment. I can't find any info on it though. I'm executing the commands from my home directory.

Can anyone help me?

March 3rd, 2010, 04:29 PM

Type the following in the terminal.

$ complete -c sudo

Now see if auto complete works..

Let me know if this helps.

March 3rd, 2010, 05:51 PM
That works! Is it better for me to add it to ~/.bashrc or /etc/bash.bashrc ?

March 4th, 2010, 05:30 AM
You might be interested in "apt-get install ubuntu-standard" to get all those useful apps (bash completion, crontab, logrotate, etc etc) as well as openssh-server.

March 4th, 2010, 09:42 AM

Adding it to ~/.bashrc will enforce it only to the user to which the home folder belongs to. Adding it to the /etc/bash.bashrc file will enforce it to all the users of the machine.

I would suggest you add it to /etc/bash.bashrc . Any user who wish to change it can do that in their own ~/.bashrc file. No harm done here.

see: http://stefaanlippens.net/bashrc_and_others

August 19th, 2010, 03:51 PM
I just spun up a new Ubuntu 10.04 server on slicehost and I couldn't sudo aptit<tab>

Found this post and noted, ubuntu-standard wasn't installed (kinda werid). Probably would be fine, there's some good stuff in there (telnet, lshw) - but also some stuff I may not need.

sudo aptitude install bash-completion

was enough to get things working for me.