sudo command doesn't autocomplete anymore on files

Try firstly reinstalling the bash-completion package with:

sudo apt-get install --reinstall bash-completion

Then backing up your .bashrc file:

mv ~/.bashrc ~/.bashrc.bak

Finally, replace your .bashrc file with the default from /etc/skel/.bashrc by using:

cp /etc/skel/.bashrc ~/

This will ensure the following 'complete' config is restored within the file:

# 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 ! 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

Also check both the containing folder and file permissions of /etc/bash.bashrc and ~/.bashrc - ownership should be root:root and yourusername:yourusergroup respectively. The permissions of the files are important as the shell only uses your own privilege level to auto-complete commands. Elevated permissions such as when sudo is invoked are only used after the command is committed by pressing enter.


Add

complete -cf sudo

to your .bashrc and .bash_profile. Autocompletion will work on next login