Updated: 12 October 2026 · Applies to: Fedora 44 (bash 5.3, bash-completion 2.17), AlmaLinux 10.2 (bash 5.2, bash-completion 2.11), Debian 13 (bash-completion 2.16), Ubuntu 24.04 (2.11) and Ubuntu 26.04 (2.16)
Autocomplete in the Linux terminal is the Tab key. Type the start of a command, file or folder name and press Tab: Bash completes it when there is only one match, and a second Tab lists all matches. Completion of options, subcommands and package names comes from the bash-completion package. Install it with sudo dnf install bash-completion (Fedora, AlmaLinux, Rocky Linux, RHEL) or sudo apt install bash-completion (Debian, Ubuntu), then open a new terminal or SSH session.
How Tab completion behaves
- One Tab: completes the word if there is only one possibility, or as far as all matches agree.
- Two Tabs: lists the possibilities, for example after
mysvc st:$ mysvc st<Tab><Tab> start status stop
- Without bash-completion, Tab only completes command names and file names. With it, Tab also completes options (
ls --sorbecomesls --sort), subcommands (dnf insbecomesdnf install,apt-get insbecomesapt-get install) and host names from~/.ssh/config(ssh wbecamessh webfor our hosts web1 and web2). We pressed these keys in an interactive Bash session on Fedora 44 and Debian 13.
Install and enable bash-completion
- Check whether completion is loaded. The number is the count of commands with their own completion; 0 means it is not loaded:
complete -p | wc -l
In our tests it was 0 without bash-completion and between 121 and 134 with it, depending on the distribution. Minimal and container images often do not include the package. - Install it:
# Fedora, AlmaLinux, Rocky Linux, RHEL sudo dnf install bash-completion # Debian, Ubuntu sudo apt install bash-completion
- Open a new terminal or log in again over SSH. To load it in the shell you already have open:
source /etc/profile.d/bash_completion.sh
In our test this took a shell from 0 to 134 completions straight away. (The script does nothing if completion is already loaded.) - Test it: type
ls --sorand press Tab.
No autocomplete as root on Debian or Ubuntu
This catches many people. After sudo su, plain su or a new terminal tab, Bash starts as a non-login shell and only reads ~/.bashrc. On Debian 13, root's .bashrc has no completion block; on Ubuntu 24.04 and 26.04 the block is there but commented out. New normal users get a working block from /etc/skel/.bashrc. In our tests root had 0 completions in a non-login shell and 121 to 122 in a login shell. On Fedora 44 and AlmaLinux 10.2, root had completion in both.
The fix, from the bash-completion documentation, is one line at the end of /root/.bashrc:
[[ $PS1 && ! ${BASH_COMPLETION_VERSINFO:-} && -f /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion
On Ubuntu 24.04 this took root's non-login shell from 0 to 134 completions. Using su - (with the hyphen) also works, because it starts a login shell; see Difference Between su and su with a Hyphen (Login Shell) in Linux and Understanding Bash Startup Files: Profile and Bashrc on Linux.
Make Tab smarter with ~/.inputrc
Bash reads its key settings from ~/.inputrc. These lines make completion ignore upper and lower case, list matches on the first Tab, and let the Up and Down arrows search the history for commands that start with what you have typed:
$include /etc/inputrc set completion-ignore-case on set show-all-if-ambiguous on "\e[A": history-search-backward "\e[B": history-search-forward
Open a new terminal afterwards. In our test, ls /tmp/t/rep plus Tab completed to Report.txt. Check the settings with bind -v | grep completion-ignore-case. To search the whole history for any part of a command, press Ctrl+R and start typing.
Add autocomplete for your own command or script
- Try it in the current shell.
complete -Wtakes a list of words:complete -W "start stop restart status" mysvc
- Make it permanent by saving the same line in your personal completion folder, which bash-completion loads on demand the first time you complete that command:
mkdir -p ~/.local/share/bash-completion/completions echo 'complete -W "start stop restart status" mysvc' > ~/.local/share/bash-completion/completions/mysvc.bash
- Open a new shell and type
mysvc resplus Tab. In our test on Ubuntu 24.04 it completed tomysvc restart.
For long commands you type often, see How to Create and Use Alias Command in Linux and Ways to Re-run the Last Executed Commands in Linux (Bash).
Suggestions while you type: fish and zsh
Bash only completes when you press Tab. If you want grey suggestions to appear as you type:
- fish has them built in. According to the fish documentation, suggestions are based on your command history, completions and valid file paths; press the Right arrow or Ctrl+F to accept one. The
fishpackage is in the standard repositories (version 4.0.2 on Debian 13, 4.2.1 on Ubuntu 26.04, 4.6.0 on Fedora 44). Install it and typefishto try it without changing your login shell. - zsh gets the same feature from the
zsh-autosuggestionspackage (0.7.1 on Debian 13, Ubuntu 26.04 and Fedora 44). On Debian and Ubuntu, add this line to~/.zshrc:source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
On a server, we suggest keeping Bash as root's login shell and starting fish or zsh only when you want it.
Official documentation: bash-completion on GitHub, GNU Bash manual.