At some moment

apt-get install

autocomplete was broken

It was very useful to me to see packages name with Tab press

How to repair this autocomplete?

  • Please edit your question to add more information. What does it do now when you press tab? Is there an error? Please include it.
    – Oli
    Dec 9 '11 at 10:21
  • What package you were trying to find? Is it available via apt-cache search mypkg I am using Kubuntu on Oneiric i see it working well.
    – koolhead17
    Dec 9 '11 at 11:18
  • For example I press tab after sudo apt-get install ruby, and terminal display me all packages with ruby: ruby-mysql, ryby-dev, etc. Dec 9 '11 at 11:51
  • Yes, and what do you see instead when you press tab?
    – Oli
    Dec 9 '11 at 11:56
  • I see folders list, like cd +[TAB] Dec 9 '11 at 11:59

As stated in the comments to the other answer, first make sure that bash-completion is installed:

sudo apt-get install bash-completion

and apparently for @diapir, it helped to reinstall it:

sudo apt-get install --reinstall bash-completion

However, for me, the problem was not that bash-completion was not installed or broken, the problem was that I had accidently deleted my .bashrc file. You can get a new one by copying it from /etc/skel:

cp /etc/skel/.bashrc ~/
  • 2
    Thanks, the bashrc tip solved the problem for me as well. The use of sudo on the chmod command is unnecessary though, right? Dec 24 '12 at 4:32
  • 2
    the file located in /etc/ is 0644/-rw-r--r-- with user:group = root:root, and when copied to your user folder, will automatically go to user:user
    – Kevin
    May 28 '14 at 17:07
  • cp /etc/skel/.bashrc ~/ helped me solve this problem. Nov 15 '15 at 8:54
  • Reinstall and copied /etc/skel/.bashrc helped me, thank you!
    – Sergey
    Apr 27 '16 at 10:19
  • I just needed to reinstall bash-completion after upgrading from Debian 9 to Debian 10 Aug 10 at 21:13

Type the following command:

sudo -H gedit /etc/bash.bashrc

Look for these lines:

# 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

Uncomment some lines, to make it look like this:

# 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

Save, close terminal, then reopen it.

I have this issue after installing 13.04, and that's how I resolve it.

  • this was the only thing that worked for me. thank you.
    – this.foo
    Nov 27 '15 at 7:40
  • Worked for me on Elementary OS LoKi Apr 5 '17 at 14:43

Note that output of this command:

apt-config dump | grep "Dir::Cache"

Should be something like this:

Dir::Cache "var/cache/apt";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";

If value of Dir::Cache::pkgcache is empty, apt will not be able to auto complete package names. Take a look at your /etc/apt/apt.conf.d/ files and search for this key to be sure that it's not set to empty string.

grep -r pkgcache /etc/apt/apt.conf.d/

Also take a look at this answer.

  • 3
    Looks like this (and the link) is the correct answer if you have this issue inside a docker container.
    – Alan Wang
    Feb 24 '20 at 14:00
  • this still works tysm! just do rm /etc/apt/apt.conf.d/docker-clean
    – Dave Ankin
    Feb 14 at 15:45

Download the latest stable release from http://bash-completion.alioth.debian.org/

sudo make install


if [ -f /etc/bash_completion ]; then
  . /etc/bash_completion

to ~/.bashrc

  • bash-completion is in packages - is there any reason you did it manually? The package should do pretty much exactly this :)
    – Caesium
    Dec 10 '11 at 12:46
  • :) as always, sitting, reading manuals, configure, and then it turns out that this soft is exists in the repository Dec 10 '11 at 12:57
  • 4
    sudo apt-get install --reinstall bash-completion did it for me.
    – diapir
    Apr 30 '12 at 0:48
  • 2
    @diapir, I have the same problem, but only reinstall does not working. I have to apply the lines in bashrc file.
    – Anwar
    May 13 '12 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.