Foundations Module 4 · Cheat Sheets

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.

💡How to use this cheat sheet

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.

Mac users: use the Control key, not Command

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

ShortcutWhat it doesWhen to use it
TabAuto-complete file/folder namesAfter typing the first few letters of a name
Up ArrowPrevious command from historyWhen you want to repeat or modify a recent command
Ctrl + CCancel/stop current processWhen something is stuck or you want to abort
Ctrl + LClear the screenWhen your terminal feels cluttered
Ctrl + DExit the terminal / end inputWhen you’re done or want to close a session
💡Tab completion is your superpower

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.

KNOWLEDGE CHECK

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.

Moving your cursor around the current command — no mouse needed.

Navigation Within a Line

Moving your cursor around the current command

ShortcutWhat it does
Ctrl + AJump to beginning of line
Ctrl + EJump to end of line
Ctrl + WDelete word before cursor
Ctrl + UDelete from cursor to beginning of line
Ctrl + KDelete from cursor to end of line
Ctrl + YPaste what you just deleted (yank)
Alt + BJump back one word (see note below)
Alt + FJump forward one word (see note below)
Alt shortcuts on macOS

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”).

TRY ITYou typed a long command but realize you need to change something at the very beginning. What shortcut jumps your cursor to the start of the line?
$

History

Navigating and searching your command history.

History

Navigating and searching your command history

ShortcutWhat it does
Up / Down arrowsScroll through previous commands
Ctrl + RSearch command history (start typing to filter)
!!Repeat the last command (Bash/Zsh only)
!$Use the last argument from the previous command (Bash/Zsh only)
historyShow full command history
history | grep keywordSearch history for a specific command
Ctrl+R is incredibly useful

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.

KNOWLEDGE CHECK

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

ShortcutWhat it does
Ctrl + CInterrupt the current foreground process (SIGINT)
Ctrl + ZSuspend (pause) the current process
fgResume a suspended process in the foreground (visible, interactive)
bgResume a suspended process in the background (runs silently)
Ctrl + DSend EOF (end of file) — at an empty prompt, exits the current shell session
TRY ITYou accidentally pressed Ctrl+Z and your running program disappeared. What command brings it back?
$

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

OperatorWhat it doesExample
&&Run next command only if first succeedsmkdir app && cd app
||Run next command only if first failstest -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 anotherls | grep ".txt"

When things go wrong

Common keyboard-related surprises and how to recover:

What happenedWhat to do
Pressed Ctrl+S and terminal frozePress Ctrl+Q to unfreeze it (Ctrl+S pauses terminal output)
Pressed Ctrl+Z and program disappearedType fg and press Enter to bring it back
Pressed Ctrl+D and terminal closedOpen a new terminal window or reconnect SSH
Ctrl+C isn’t stopping the processTry 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 errorThese 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.

Symptom
Ctrl+C doesn't stop the process
Evidence
Process keeps running after pressing Ctrl+C
What to ask the AI
"I pressed Ctrl+C but the process won't stop. What's a stronger way to kill it? Should I try Ctrl+Z and then 'kill' the process?"
Symptom
Terminal seems frozen, nothing I type appears
Evidence
Keyboard input produces no visible output
What to ask the AI
"My terminal looks frozen and won't accept input. You likely pressed Ctrl+S by accident, which pauses terminal output. Press Ctrl+Q to unfreeze it."
Symptom
Tab completion doesn't work
Evidence
Pressing Tab does nothing or beeps
What to ask the AI
"Tab auto-complete isn't working in my terminal. Is this a shell configuration issue? How do I enable it?"

Try it now

Open your terminal and run through this quick practice:

Terminal window
# 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 command

If 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:

  1. Week 1: Tab, Up Arrow, Ctrl+C — these three alone transform your experience
  2. Week 2: Add Ctrl+L, Ctrl+A, Ctrl+E
  3. Week 3: Add Ctrl+R for history search
  4. 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.