Okay a college of mine just showed me that you could do

sudo apt-get install <type first letters of package> <TAB>

That it auto-completes the name of the package. Just for an example...

sudo apt-get install ged<TAB> results in sudo apt-get install gedit

Now I tried to do this but this does not work for me.

How can I solve this? Do I have to install a package? My college told me that he didn't install anything extra for it.

  • No because auto completion still works for commands and folders etc... Just not for packages.
    – WG-
    Commented Oct 30, 2012 at 20:56
  • That's exactly what that question is about? Maybe the answer isn't to your liking, but that is another thing. The question linked is about autocompletion of packages..
    – Nanne
    Commented Oct 30, 2012 at 21:15
  • @WG- Sorry, I misunderstood what you were saying. Commented Jan 29, 2013 at 13:40

7 Answers 7


Bash does support some more kinds of autocompletion, not only filename completion.

In the file /etc/bash.bashrc, you will find a paragraph, like this or similiar to 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
#  fi

(this example is from debian, but is probably identical to the Ubuntu version)

By removing the # character in the beginning of each line you put a lot of additional completion rules into effect. (Don't remove the # on the first line... thats really a comment ;-)

I believe apt-get completions are among those enabled with this. If not you could think about switching to zsh. I know they support it ;-)

  • What other autocompletions are supported?
    – nanofarad
    Commented Nov 8, 2012 at 22:47
  • @obsessivesso: that is customizable and extendable. See for example github.com/revans/bash-it/tree/master/completion/available
    – knb
    Commented Nov 22, 2012 at 14:55
  • I had to restart my server before this would work for me. Now I can tab complete package names. Note that I also enabled these lines in the .bashrc file of my user's home directory. /home/user/.bashrc
    – iyrin
    Commented Jan 6, 2014 at 10:02
  • You should only need to restart the terminal (bash) not the whole server. Also, this seems to be disable on Mint 18 for unknown reasons where it was uncommented on previous versions. Anyway, great answer, saves a ton of misery!
    – Nick
    Commented Feb 18, 2017 at 2:23
  • Just had to do this on Ubuntu 20.04 server version to get apt completion. The bash-completion package was already installed.
    – Geekman
    Commented Nov 26, 2020 at 1:14

I found that on mine this was happening because bash-completion was not installed for some reason. So this fixed it (12.04):

sudo apt-get install bash-completion
  • 1
    The change will not take effect immediately after installing the package. The shell needs to be restarted, or its settings reloaded, for the new tab-completions to be loaded. Commented Feb 17, 2015 at 19:50
  • 1
    do ". ~/.bashrc" it is "<DOT><SPACE><tilde><forwad-slash><DOT><bashrc>" This will reload the config file. No need to restart the shell. Commented Feb 23, 2016 at 10:50

I had the same problem after installing Ubuntu 15.10.
Reinstalling bash-completion worked for me :

sudo apt-get install --reinstall bash-completion
  • 1
    This worked for me in Debian Jessie 8.4 as well.
    – user373531
    Commented May 16, 2016 at 9:04

In Ubuntu it started to irritate me too, so I just did (in terminal):

gksu gedit /etc/bash.bashrc

and changed

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


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

now it works like I want it to again... HTH :)

It is different from the example Paul Hänsch gave, mine came from ubuntu 12.04. I am not sure what Pauls version would do exactly, maybe he could elaborate on that a bit?


Another issue can be a failed apt-get update. After removing the wrong sources, and running apt-get update, I got my autocomplete restored.

  • Indeed, none of the other answers solved this problem for me, but this one did for Ubuntu 14.04.2 LTS Raspberry version. Thanks you for sharing. Commented Jun 9, 2015 at 1:52

Open a Terminal and

sudo apt-get install bash-completion

After I installed bash-completion, this issue is fixed in my side.


this happens to me when either:

  1. I use my university pc where I can't use the autocomplete because am not a super user.

  2. The ppa of the package that you are trying to download is not in your source.list. So the terminal can't recognize the package that you are trying to download.

NOTE: This may not apply to everyone. Am just sharing my experience

Not the answer you're looking for? Browse other questions tagged .