Keyboard Shortcuts & Tab Completion: Work Faster at the Prompt
Most beginners type every character twice as hard as necessary — a handful of key combinations make the shell feel like an extension of your hands — this page is the full collection.
Why Learn This?
Every hour you spend retyping paths, pressing the up arrow thirty times to find one old command, or hunting for a misspelled word is time wasted. The shortcuts on this page are used by every experienced Linux user dozens of times a day, and none of them require memorizing anything exotic.
Learn
Tab,Ctrl+C,Ctrl+R, and the arrow keys first. Those four alone cover most of what a beginner needs, and the rest you will pick up as you actually use them.
1. Tab Completion: The Single Best Shortcut
Tab completion asks the shell to finish what you typed. Start typing a path or command name and press Tab:
cd /etc/ssl/
The shell completes the rest for you. If several things match, press Tab twice to list them:
ls /etc/pass
# passwd passwd-
This works for:
- Paths —
cd /usr/lo+Tab→cd /usr/local - Commands — type a partial command and
Tabcompletes it from$PATH - Arguments of some commands —
apt instal+Tabcan complete package names on some systems - Variables —
$HOM+Tab→$HOME
git checkout fea
git checkout feature/login-form
Why it matters
- You never type a long path twice
- You catch typos immediately (no match = nothing happens, which is the signal)
- Pressing
TabTabis a free listing of everything that starts with those letters
Example: completing a deep path without typing it at all:
cat /var/log/nginx/erro
# press Tab twice:
# error.log error.log.1 error.log.2.gz
cat /var/log/nginx/error.log
2. Moving and Editing on the Line
| Shortcut | What it does |
|---|---|
Ctrl + A | Jump to the start of the line |
Ctrl + E | Jump to the end of the line |
Alt + F | Forward one word |
Alt + B | Back one word |
Ctrl + U | Cut everything from the cursor to the start |
Ctrl + K | Cut everything from the cursor to the end |
Ctrl + W | Cut the word before the cursor |
Ctrl + Y | Paste back what you just cut |
Ctrl + L | Clear the screen (same as clear) |
Ctrl + D | Send end-of-input (logout, or delete a character when line is empty) |
The editing keys (Ctrl + A/E, Alt + F/B) follow the same conventions as most modern tools, so they transfer to Python’s REPL, MySQL, and plenty of other programs.
Example: fix a typo somewhere in the middle of a long command:
apt-get install -y nginx.conf
Ctrl + A → Alt + F × 3 → Alt + B to land on the mistake, delete it, retype, then Ctrl + E to jump back to the end and press Enter.
3. History: The Up Arrow and Beyond
| Shortcut | What it does |
|---|---|
↑ / ↓ | Previous / next command in history |
Ctrl + R | Search history backwards as you type |
Ctrl + G | Escape out of a Ctrl + R search |
!string | Run the most recent command starting with string |
!! | Re-run the last command |
!$ | The last argument of the previous command |
Ctrl + R is the one beginners fall in love with fastest:
(reverse-i-search)`chm': chmod 755
(reverse-i-search)`chm': chmod 644 /var/www/site/index.html
Example: !! after forgetting sudo:
apt install htop
# Permission denied...
sudo !!
4. Interrupting, Suspending, and Clearing
| Shortcut | What it does |
|---|---|
Ctrl + C | Send SIGINT — kill the foreground process |
Ctrl + Z | Suspend the foreground process (resume with fg) |
Ctrl + D | End of input — close the shell, or EOF for programs like cat |
Ctrl + L | Clear the visible screen |
Ctrl + S | Freeze the screen (yes, really — Ctrl + Q unfreezes) |
q | Quit programs that use it (less, top, man) |
Ctrl + C and Ctrl + Z are the two you will use constantly. Process management (fg, bg, kill) is covered in a later phase — for now, just know these two keys exist and what they feel like.
Example: Ctrl + D is how you exit cat when it is waiting for input:
cat
hello
world
^D # Ctrl+D — cat exits because input ended
5. Copy, Paste, and Terminal-Specific Keys
Terminal clipboard behavior varies by terminal, which surprises everyone once:
| Shortcut | Terminal emulator | Notes |
|---|---|---|
Ctrl + Shift + C / Ctrl + Shift + V | Most Linux terminals | The default on GNOME Terminal, Konsole, etc. |
Cmd + C / Cmd + V | macOS Terminal, iTerm2 | macOS convention |
Shift + Insert | Almost anything | Pastes from the system clipboard |
| Middle-click | Any X11 terminal | Pastes the primary selection |
There is no bare Ctrl + C / Ctrl + V for copy/paste in Linux terminals — Ctrl + C means “interrupt”. This is the single most common confusion for people coming from Windows.
Example: copying a long path out of ls output into another command: select the text with the mouse, then middle-click (or Ctrl + Shift + V) at the prompt.
6. Ctrl + Alt + Function Keys and Virtual Consoles
When a graphical session is frozen, Ctrl + Alt + F2 through F6 switch to a text-only login console, and Ctrl + Alt + F1 (or F7/F2, depending on your distro) returns to the desktop. This is a rescue route, not a daily driver, but knowing it exists prevents panic when the GUI dies.
7. Customizing Shortcuts
The shell reads key bindings from a configuration file. In bash that is ~/.inputrc, in zsh ~/.zshrc:
# ~/.inputrc — make Delete work like Backspace, and bind arrows to history search
set completion-ignore-case on
"\e[A": history-search-backward
"\e[B": history-search-forward
After editing ~/.inputrc, open a new terminal or run bind -f ~/.inputrc to reload.
Example: history-search-backward means pressing ↑ after typing git only shows previous commands that started with git — far faster than blind arrow-key scrolling.
Common Pitfalls
- Expecting
Ctrl+Cto copy — in a Linux terminal it interrupts; useCtrl+Shift+Cor mouse selection. Ctrl+Sfreezing the screen — it is not a bug, it is flow control; pressCtrl+Qto continue.Ctrl+Dlogging you out — when you meant “cancel”, press it on an empty line it exits the shell. UseCtrl+Cfor cancel.Altkeys doing nothing in some terminals — some emulators need “Alt acts as Meta” enabled, or useEscthen the key as a fallback (Escf= forward word).- Relying on
historyacross sessions — by default each shell writes history on exit; commands from a shell you killed withkill -9may be lost. - Thinking Tab completion is magic — it only completes from
$PATH, the filesystem, and shell knowledge; a brokenPATHbreaks command completion too.
Related Pages
| Page | Why it is related |
|---|---|
| Opening a Terminal | Where these shortcuts apply |
| Terminal vs Shell vs Kernel | The shell is what interprets these keys |
| history and shell basics | Ctrl + R and history are the same feature |
Keyboard Shortcuts Cheatsheet
| Keys | Action |
|---|---|
Tab | Complete a path or command |
Tab Tab | List all matches |
Ctrl + C | Kill the foreground process |
Ctrl + Z | Suspend it (resume with fg) |
Ctrl + D | End input / exit shell |
Ctrl + L | Clear the screen |
Ctrl + R | Search command history |
Ctrl + A / Ctrl + E | Start / end of line |
Alt + F / Alt + B | Word forward / back |
Ctrl + U / Ctrl + K / Ctrl + W | Cut to start / end / word |
Ctrl + Y | Paste cut text |
!! | Re-run last command |
Ctrl + Shift + C / V | Copy / paste (Linux terminals) |