enable apt-get autocomplete

Debian Administration

I was wondering how to enable auto complete of packages for apt-get command in Backtrack linux. I recalled a day when I firstly installed Ubuntu on my laptop, and I was searching for a way to manipulate packages. I was not able to know every package nor versioning. Thus, searching on the Internet I finally found the bash_completion. This is a utility with very powerful abilities for users and programmers. In order to understand better what bash_completion is, I advice you to take a look at debian’s article about bash_completion utility .


Now lets tell how to enable this feature if not already enabled.  There are two ways both includes shell commands and the changes last for the terminal session you use.


source /etc/bash_completion


. /etc/bash_completion

From now on you are able to use Tab key to autocomplete / suggest commands like:

apt-get ins [TAB]
apt-get install dove[TAB]
apt-get install dovecot[TAB]
dovecot dovecot-gssapi dovecot-pgsql
dovecot-antispam dovecot-imapd dovecot-pop3d
dovecot-common dovecot-ldap dovecot-postfix
dovecot-core dovecot-lmtpd dovecot-sieve
dovecot-dbg dovecot-managesieved dovecot-solr
dovecot-dev dovecot-mysql dovecot-sqlite
apt-get install dovecot dovecot-antispam dovecot-ldap

If you want to permanently enable this utility you have to edit your



vi /etc/bashrc

You have to find the following lines in this file:

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


and uncomment (deleting the #) the following lines

if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion

This how to, tutorial enable apt-get autocomplete, is the same for all debian based distributions like ubuntu, linux mint, debian, kubuntu, backtrack linux and more…


3 Replies to “enable apt-get autocomplete”

  1. On debian 7 it’s actually in /etc/bash.bashrc and should look like that:

    # 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

Leave a Reply

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

Prove me that you are not a robot :) * Time limit is exhausted. Please reload the CAPTCHA.