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.

2 thoughts on “Bash Tab Autocomplete Not Working on Linux”
  1. Docker tab automatic prompt under Ubuntu does not work
    Manually copy /usr/share/bash-completion/completions to /etc/bash_completion.d
    I found that there are many commands in it
    If something’s not right, I’ll check it out.
    Just reinstall it and it’ll be fine
    $ sudo apt install –reinstall bash-completion

  2. I’ve been pulling my hair out over this broken tab completion for weeks, and the solution was so simple I could’ve facepalmed. It’s like trying to do a bottle flip with no practice – just frustrating until you get the hang of it.

Leave a Reply

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