Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 Tab completes it from $PATH
  • Arguments of some commands — apt instal + Tab can 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 Tab Tab is 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

ShortcutWhat it does
Ctrl + AJump to the start of the line
Ctrl + EJump to the end of the line
Alt + FForward one word
Alt + BBack one word
Ctrl + UCut everything from the cursor to the start
Ctrl + KCut everything from the cursor to the end
Ctrl + WCut the word before the cursor
Ctrl + YPaste back what you just cut
Ctrl + LClear the screen (same as clear)
Ctrl + DSend 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

ShortcutWhat it does
↑ / ↓Previous / next command in history
Ctrl + RSearch history backwards as you type
Ctrl + GEscape out of a Ctrl + R search
!stringRun 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

ShortcutWhat it does
Ctrl + CSend SIGINT — kill the foreground process
Ctrl + ZSuspend the foreground process (resume with fg)
Ctrl + DEnd of input — close the shell, or EOF for programs like cat
Ctrl + LClear the visible screen
Ctrl + SFreeze the screen (yes, really — Ctrl + Q unfreezes)
qQuit 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:

ShortcutTerminal emulatorNotes
Ctrl + Shift + C / Ctrl + Shift + VMost Linux terminalsThe default on GNOME Terminal, Konsole, etc.
Cmd + C / Cmd + VmacOS Terminal, iTerm2macOS convention
Shift + InsertAlmost anythingPastes from the system clipboard
Middle-clickAny X11 terminalPastes 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 + C to copy — in a Linux terminal it interrupts; use Ctrl + Shift + C or mouse selection.
  • Ctrl + S freezing the screen — it is not a bug, it is flow control; press Ctrl + Q to continue.
  • Ctrl + D logging you out — when you meant “cancel”, press it on an empty line it exits the shell. Use Ctrl + C for cancel.
  • Alt keys doing nothing in some terminals — some emulators need “Alt acts as Meta” enabled, or use Esc then the key as a fallback (Esc f = forward word).
  • Relying on history across sessions — by default each shell writes history on exit; commands from a shell you killed with kill -9 may be lost.
  • Thinking Tab completion is magic — it only completes from $PATH, the filesystem, and shell knowledge; a broken PATH breaks command completion too.

PageWhy it is related
Opening a TerminalWhere these shortcuts apply
Terminal vs Shell vs KernelThe shell is what interprets these keys
history and shell basicsCtrl + R and history are the same feature

Keyboard Shortcuts Cheatsheet

KeysAction
TabComplete a path or command
Tab TabList all matches
Ctrl + CKill the foreground process
Ctrl + ZSuspend it (resume with fg)
Ctrl + DEnd input / exit shell
Ctrl + LClear the screen
Ctrl + RSearch command history
Ctrl + A / Ctrl + EStart / end of line
Alt + F / Alt + BWord forward / back
Ctrl + U / Ctrl + K / Ctrl + WCut to start / end / word
Ctrl + YPaste cut text
!!Re-run last command
Ctrl + Shift + C / VCopy / paste (Linux terminals)