How To Add Bash Completion In Debian

Want to support HowtoForge? Become a subscriber!
Submitted by sjau (Contact Author) (Forums) on Thu, 2009-04-30 12:15. :: Debian

How To Add Bash Completion In Debian

Author: Stephan Jau
Revision: v1.0
Last Change: April 26 2009


Bash completion is a useful tool for completion of file paths, commands etc. By default it is enabled on Ubuntu but not on Debian. With two simple steps it can also be enabled on Debian.


1. Install bash-completion

First of all we need the install the according package:

apt-get install bash-completion


2. Add it to the bash profile

Either edit the ~/.bash_profile file to enable it only for a given user or edit /etc/profile to add it system-wide. Add the following code:

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


3. Try it

In order for it to work you have to log out and relogin and then you can make use of bash completion the usual way. E.g. issue:


and then press the TAB key once and the command will be completed to apt-get. Or issue this:


and then press TAB key twice. You can also try with

apt-get install apa

and then press TAB key once to complete as far as possible and a second time to list all options.

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Wed, 2010-05-19 05:09.

Hi, please, check out bash completion script for clearcase UNIX tools. Cheers, Jan.

Submitted by nadavkav (not registered) on Sat, 2009-05-02 21:00.

as far as i can remember it was always ON :-)

but it is always good to know how to turn it off too.

thanks !

Submitted by Piki (not registered) on Thu, 2009-04-30 19:06.
Ekhm? I have always thought that the completion system was always ON in Debian? I have never needed to turn it on?
Submitted by Russ (not registered) on Thu, 2009-04-30 14:15.
Why would you install an external package? I mean, the completion support is already there. You uncomment the bash completion part in /etc/bash.bashrc and then just source this file in /etc/profile
Submitted by Stuart (not registered) on Mon, 2009-05-04 10:58.

Only bash completion for filenames and directories is enabled by default -- bash completion for options and restricting filenames requires the installation of the bash-completion package from lenny onwards.

The completion of "apt-get i" to "apt-get install" will work only with the bash-completion package installed... unless you have a file called "install" in that directory.

   apt-cache show bash-completion

(read first, reply second)

Submitted by Alex (not registered) on Tue, 2009-05-05 07:07.

I've just installed my Debian and the completion works out-of-the-box for all options and filenames. The bash_completion package was installed by default.

Submitted by sjau (registered user) on Fri, 2010-01-22 10:44.
did you install a minimal system or just default server?