Bash Tab Autocomplete Not Working on Linux

PowerADM.com / Linux / CentOS / Bash Tab Autocomplete Not Working on Linux

In this article, we’ll show you how to fix the broken tab completion feature in the Linux bash console.

On Ubuntu/Debian, you need to install the bash-completion package:

$ sudo apt install bash-completion

If the package is installed, but the autocomplete doesn’t work, reinstall it:

$ sudo apt install --reinstall bash-completion

If the problem persists, check the settings in the bash config file (/root/.bashrc):

Check that the file exists, if the file doesn’t exist, you can copy its template to the user’s home directory:

$ cp /etc/skel/.bashrc ~/

Now open the .bashrc file for editing:

$ sudo nano /root/.bashrc

Check that the following lines are present at the end of the config file:

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

Bash tab-completion not working in LInux

Save the file: Ctrl+X, Y -> Enter.

Close your bash session:

$ exit

Log in again and check that command completion is now working in the Linux CLI.

Leave a Reply

Your email address will not be published. Required fields are marked *