Terminal Fundamentals
Core terminal concepts: terminal emulator vs. shell, standard keyboard shortcuts, piping, redirection, and essential CLI navigation.
Terminal Fundamentals
The Command Line Interface (CLI) is the most direct way to interact with an operating system. Becoming proficient in the terminal accelerates development workflows, unlocks automation scripting, and is required for managing remote cloud servers.
1. Terminal Emulator vs. Shell
Developers often use these terms interchangeably, but they perform distinct functions:
| Component | Definition | Examples |
|---|---|---|
| Terminal Emulator | The graphical GUI window that displays text, receives keyboard keystrokes, and handles font/color rendering. | Ghostty, iTerm2, Alacritty, VS Code integrated terminal, Windows Terminal |
| Shell | The text-based command interpreter program running inside the terminal that parses inputs, executes binaries, and manages environment state. | zsh (macOS default), bash (Linux default), fish, PowerShell |
2. Essential Keyboard Shortcuts
Mastering keyboard shortcuts prevents tedious typing mistakes:
| Shortcut | Action |
|---|---|
Ctrl + C | Send SIGINT interrupt signal to immediately kill/stop the currently running command. |
Ctrl + L (or clear) | Clear the terminal viewport without deleting session history. |
Ctrl + A / Ctrl + E | Jump cursor to the very beginning / end of the current command line. |
Ctrl + U / Ctrl + K | Cut everything from cursor to the beginning / end of line. |
Ctrl + R | Interactive reverse history search (type characters to find previous commands). |
Tab | Autocomplete filename, directory path, or command flags. |
Up / Down Arrows | Cycle through previous command history. |
3. Standard Streams, Redirection & Pipes
Every terminal program executes with three default I/O streams:
stdin(0): Standard Input (keyboard keystrokes or piped text).stdout(1): Standard Output (normal program results printed to screen).stderr(2): Standard Error (diagnostic error messages printed to screen).
Stream Redirection Operators
# Overwrite file with stdout:
echo "DATABASE_URL=postgres://..." > .env
# Append stdout to end of file without overwriting:
echo "PORT=3000" >> .env
# Redirect stderr to a log file:
pnpm build 2> build-errors.log
# Discard all output (black hole):
npm test > /dev/null 2>&1Piping (|)
The pipe operator | connects the stdout of one command directly into the stdin of the next command:
# Search for active node processes:
ps aux | grep node
# Count how many typescript files exist in src/:
find src/ -name "*.tsx" | wc -lRelated Topics
Absolute vs. Relative Paths
Mastering filesystem paths: root slash (/), current directory (.), parent directory (..), home shortcut (~), and path resolution rules.
Shell Fundamentals & Scripting
Mastering shell interpreters: bash vs. zsh, configuration files (.zshrc, .bashrc), PATH variable, aliases, and shell scripting basics.