enable apt-get autocomplete

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…

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.

1st:

source /etc/bash_completion

2nd:

. /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

 /etc/bashrc

file

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
#fi

 

and uncomment (deleting the #) the following lines

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

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…