Keyboard Shortcuts
What you'll learn
~8 min- Use Tab completion to avoid typing long file names
- Cancel stuck commands and clear your screen
- Navigate and edit text on the command line without a mouse
- Search your command history to reuse previous commands
By the end of this lesson, you will know the handful of keyboard shortcuts that separate a frustrating terminal experience from a smooth one. These are small moves that make a big difference.
Bookmark this page. You don’t need to memorize every shortcut — come back whenever you need one. Start with the 5 shortcuts you use most and add more over time.
Mental model: keyboard shortcuts are muscle memory, like driving
When you first learned to drive, you thought about every action — mirror, signal, brake. Now you do it without thinking. Terminal shortcuts work the same way. At first you will glance at this page. After a week of practice, your fingers will just know.
The good news: you only need about five shortcuts to feel fast. Everything else is a bonus.
For all shortcuts on this page, use the actual Control (Ctrl) key, not the Command (Cmd) key. On macOS, Cmd+C copies text, but Ctrl+C interrupts a running process. These are completely different actions in the terminal.
The essential five
Learn these first — they are the ones you will use every single day.
The Essential Five
Learn these first — they're the ones you'll use every day
| Shortcut | What it does | When to use it |
|---|---|---|
| Tab | Auto-complete file/folder names | After typing the first few letters of a name |
| Up Arrow | Previous command from history | When you want to repeat or modify a recent command |
| Ctrl + C | Cancel/stop current process | When something is stuck or you want to abort |
| Ctrl + L | Clear the screen | When your terminal feels cluttered |
| Ctrl + D | Exit the terminal / end input | When you’re done or want to close a session |
Instead of typing cd my-really-long-project-name, type cd my and press Tab. If there’s only one match, it completes instantly. If there are multiple matches, press Tab twice to see all options. This works for commands, file names, and folder names.
A command has been running for a long time and seems stuck. What keyboard shortcut stops it?
🧬In Your Field: Biotechclick to expand
Running a long bioinformatics pipeline and realize you passed the wrong input file? Press Ctrl + C immediately to stop it, fix the command using Up Arrow to recall it, edit the filename, and press Enter. This saves you from waiting 20 minutes for a result you know is wrong.
🏛️In Your Field: Government / State Devclick to expand
Government networks sometimes have long SSH timeouts or slow connections. If a command hangs after connecting to a remote server, Ctrl + C is your escape hatch. And Up Arrow is invaluable when you need to re-run deployment commands you typed five minutes ago.
Navigation within a line
Moving your cursor around the current command — no mouse needed.
Navigation Within a Line
Moving your cursor around the current command
| Shortcut | What it does |
|---|---|
| Ctrl + A | Jump to beginning of line |
| Ctrl + E | Jump to end of line |
| Ctrl + W | Delete word before cursor |
| Ctrl + U | Delete from cursor to beginning of line |
| Ctrl + K | Delete from cursor to end of line |
| Ctrl + Y | Paste what you just deleted (yank) |
| Alt + B | Jump back one word (see note below) |
| Alt + F | Jump forward one word (see note below) |
On macOS, Alt+B and Alt+F may not work by default (they can produce special characters like ∫ or ƒ). Instead, use Esc then B or Esc then F as a universal alternative. You can also enable “Use Option as Meta key” in your terminal’s settings (Terminal.app: Profiles -> Keyboard -> “Use Option as Meta key”; iTerm2: Profiles -> Keys -> “Option key acts as Meta”).
History
Navigating and searching your command history.
History
Navigating and searching your command history
| Shortcut | What it does |
|---|---|
| Up / Down arrows | Scroll through previous commands |
| Ctrl + R | Search command history (start typing to filter) |
| !! | Repeat the last command (Bash/Zsh only) |
| !$ | Use the last argument from the previous command (Bash/Zsh only) |
history | Show full command history |
history | grep keyword | Search history for a specific command |
Press Ctrl+R, then start typing part of a command you used before. The terminal will search your history and show the most recent match. Press Ctrl+R again to cycle through older matches. Press Enter to run it, or Ctrl+G to cancel and return to an empty prompt. (Esc behavior varies by shell — it may accept the match for editing rather than canceling.) This is one of the biggest time-savers once you get used to it.
You ran a complex command 30 commands ago and want to find it quickly. What is the fastest shortcut?
📊In Your Field: MIS / Businessclick to expand
In business analytics workflows, you often run the same data export or report generation commands repeatedly. Ctrl + R becomes essential: type export or report and it finds your last matching command instantly. You can also use !! to re-run the last command — handy when you forgot to add sudo (just type sudo !!).
Process control
Managing running commands.
Process Control
Managing running commands
| Shortcut | What it does |
|---|---|
| Ctrl + C | Interrupt the current foreground process (SIGINT) |
| Ctrl + Z | Suspend (pause) the current process |
fg | Resume a suspended process in the foreground (visible, interactive) |
bg | Resume a suspended process in the background (runs silently) |
| Ctrl + D | Send EOF (end of file) — at an empty prompt, exits the current shell session |
Bonus: useful shell operators
These are typed characters, not simultaneous keyboard shortcuts — but they save just as many keystrokes.
Useful Operators
Combining and redirecting commands
| Operator | What it does | Example |
|---|---|---|
&& | Run next command only if first succeeds | mkdir app && cd app |
|| | Run next command only if first fails | test -f file || echo "not found" |
> | Redirect output to file (overwrite) | echo "hello" > file.txt |
>> | Redirect output to file (append) | echo "more" >> file.txt |
| | Pipe output of one command to another | ls | grep ".txt" |
When things go wrong
Common keyboard-related surprises and how to recover:
| What happened | What to do |
|---|---|
| Pressed Ctrl+S and terminal froze | Press Ctrl+Q to unfreeze it (Ctrl+S pauses terminal output) |
| Pressed Ctrl+Z and program disappeared | Type fg and press Enter to bring it back |
| Pressed Ctrl+D and terminal closed | Open a new terminal window or reconnect SSH |
| Ctrl+C isn’t stopping the process | Try again, or use Ctrl+Z then kill %1 to force-stop. On Windows/PowerShell, open a second terminal and use taskkill or Task Manager instead |
Stuck at a : prompt (in less or man) | Press q to quit |
!! or !$ shows an error | These are Bash/Zsh features. Use Up Arrow or Ctrl+R instead |
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
Try it now
Open your terminal and run through this quick practice:
# 1. Type this but DON'T press Enter yet:echo "hello world from the terminal"# 2. Press Ctrl+A to jump to the beginning# 3. Press Ctrl+E to jump to the end# 4. Press Ctrl+U to clear the line# 5. Now type: sleep 30# 6. Press Enter, then immediately press Ctrl+C to stop it# 7. Press Up Arrow to recall the sleep commandIf you made it through, you’ve practiced the most important shortcuts.
Building muscle memory
You don’t need to memorize all of these at once. Here is a learning sequence:
- Week 1: Tab, Up Arrow, Ctrl+C — these three alone transform your experience
- Week 2: Add Ctrl+L, Ctrl+A, Ctrl+E
- Week 3: Add Ctrl+R for history search
- Beyond: The rest will come naturally as you work
The goal is not to memorize a table — it is to reach for these shortcuts instinctively. That only happens through practice.
Key takeaways
- Tab completion saves more keystrokes than any other shortcut. Use it constantly.
- Ctrl + C is your emergency stop button. Whenever something seems stuck, press it.
- Up Arrow and Ctrl + R let you reuse previous commands instead of retyping them.
- You only need 5 shortcuts to feel comfortable. The rest are nice-to-have bonuses.
- Muscle memory develops with regular practice — often within days to weeks. Be patient with yourself.
🔍Customizing your shortcuts
If you use Zsh (the default shell on modern macOS), you can install plugins like zsh-autosuggestions that show ghost text of your previous commands as you type. It is like Tab completion on autopilot.
You can also create aliases in your shell configuration file (~/.bashrc or ~/.zshrc) to turn long commands into short ones. For example, adding alias ll='ls -la' means you can type ll instead of ls -la.
These customizations are completely optional and not covered in this course, but they are fun to explore once you are comfortable with the basics.