I am currently running 64-bit Debian Wheezy.

I am having some trouble with auto completion for apt-get. I have bash-completion installed.

If I am logged in as root in a shell, I can use auto completion for apt-get (ex: apt-get install wicd[tab][tab]) and it will show me all the packages that match that. But if I try to use auto completion for apt-get in another non-root user (even with sudo) it will not work at all. I can auto complete other things like file names.

Any help?

I do have the following code in my .bashrc and /etc/profile

 if [ -f /etc/bash_completion ]; then
      . /etc/bash_completion
  • 1
    First, check whether root and the other users have the same shell. If not, that's the reason for the different behaviour. Otherwise, try this: ‘apt-cache --no-generate pkgnames "wicd"’. Does it work? That's what bash uses to generate the completion of ‘apt-get install wicd[TAB]’.
    – angus
    Jan 12, 2012 at 0:10
  • They are both using the same shell, bash. the apt-cache command you gave me does work and shows a list of all the wicd packages. Also, what I found out is when my computer first boots up and I log into the shell for the first time ( I do not have a gui log in), the apt-get autocompletion will work with any account. But if I run my fvwm-crystal window manager with startx, then open a terminal, it will not work again with just my user account. It still works with root in fvwm-crystal. Jan 12, 2012 at 16:54
  • OK, this is what can be happening. /etc/profile and .bash_profile are run on login shells. That is, when you login on the console, or when you run ‘su’. Since in those cases completion works, /etc/profile is working. What's left is ~/.bashrc. Check that the line ‘. /etc/bash_completion’ is really being executed. Put something like ‘echo OK’ before it, open a new terminal, and check it says ‘OK’.
    – angus
    Jan 12, 2012 at 20:15
  • did you ever tested ZSH ? May 13, 2012 at 9:45
  • Your .bashrc might be completely missing; this was my case
    – Galvani
    May 14, 2015 at 5:11

4 Answers 4


Your /etc/bash_completion file must be missing.

sudo apt-get install bash-completion

should solve all your problems.

Given that you already have lines uncommented in /etc/bash.bashrc as Faheem Mitha and others pointed out, it should work now:

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

Reason: The bash-completion package now has that file (/etc/bash_completion). It used to be in the bash package, but not any more.

info on package change

  • what should be in the /etc/bash_completion file? I ran the install bash-completion command and everything is already the latest version but my bash completion file is empty Aug 28, 2016 at 18:15
  • look for a section which has "bash_completion" commented out and uncomment it, or if it doesn't exist, insert the snippet provided by n611x007 Mar 16, 2022 at 11:06

I can't remember if this is necessary, but try uncommenting the corresponding lines from /etc/bash.bashrc if not already uncommented, namely

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

Try running this:

chsh -s /bin/bash $USER

As I remember, bash autocompletion for command parammeters is done via the complete command. You should have an apt-get completion script loaded by the root user bashrc (maybe /root/.bashrc), so you need root login to run it. Sudo does not load root login scripts, it just gives you privileges.

Maybe you're missing that autocompletion script for non-root users, so they don't have bash autocompletion configured for apt-get. If that is true, load that functions for users having ALL privileges within the sudoers file.

You must log in to answer this question.

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