Autocompletion doesn't work while logged as root

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.


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


For Ubuntu 13.10, check /etc/bash.bashrc for

# enable bash completion in interactive shells
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

They might be commented. Un-commenting them works.