What is tab completion in bash?
Tab completion lets you type the first few characters of a command or filename and press Tab to have the shell finish it for you — saving keystrokes and, more importantly, preventing typos.
It's not just a convenience; it's a correctness tool. Because the shell completes only against things that actually exist, a name it completes is guaranteed to be spelled right and to be really there. That alone eliminates a whole class of "No such file" mistakes.
cd /ho[TAB] → cd /home/
cd /home/lab[TAB] → cd /home/labstudent/
systemc[TAB] → systemctl
The behaviour when input is ambiguous is the part people miss:
- Tab once — completes immediately if there's a single match; otherwise it fills in as far as the matches agree, then stops.
- Tab twice — lists every possibility so you can see your options and type one more character to disambiguate.
ls /etc/pa[TAB][TAB]
pam.conf pam.d/ passwd passwd-
It works on more than filenames: commands in your $PATH`, options (with the `bash-completion` package), `ssh` hostnames, and variable names after `$.
Tip: make Tab a reflex — type a few letters and tab before you finish typing. Over a day it saves enormous time, and "Tab gives me nothing" is itself useful information: the thing you're typing probably doesn't exist or isn't where you think.