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?
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.
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 .
!).
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.
sudo cat /root/.bashrc
?