The terminal (also called command line, shell, or console) is a text-based way to control your computer. Instead of clicking buttons and icons, you type commands.
It looks intimidating at first. But once you learn 10-15 commands, you’ll wonder how you ever lived without it.
Why developers use the terminal
- It’s faster. Renaming 500 files takes one command, not 500 clicks.
- It’s more powerful. Many developer tools only work from the terminal (Git, npm, Docker).
- It’s scriptable. You can save commands in a file and run them automatically.
- Servers don’t have GUIs. When you manage a server, the terminal is all you have.
Opening the terminal
- macOS: Cmd+Space → type “Terminal” → Enter (or use iTerm2)
- Windows: Search “PowerShell” or install Windows Terminal
- Linux: Ctrl+Alt+T (or search “Terminal”)
Essential commands
Moving around
pwd # Where am I? (Print Working Directory)
ls # List files in current directory
ls -la # List ALL files with details (including hidden)
cd Documents # Go into the Documents folder
cd .. # Go up one level
cd ~ # Go to home directory
cd / # Go to root directory
Files and folders
mkdir my-project # Create a folder
touch index.html # Create an empty file
cp file.txt backup.txt # Copy a file
mv old.txt new.txt # Rename (or move) a file
rm file.txt # Delete a file (no trash — it's gone!)
rm -r folder/ # Delete a folder and everything in it
Reading files
cat file.txt # Print entire file
head file.txt # First 10 lines
tail file.txt # Last 10 lines
tail -f log.txt # Follow a file (see new lines as they're added)
less file.txt # Scroll through a file (press q to quit)
Searching
grep "error" log.txt # Find lines containing "error"
grep -r "TODO" src/ # Search recursively in a directory
find . -name "*.js" # Find files by name
find . -name "*.log" -delete # Find and delete
System info
whoami # Current user
hostname # Computer name
df -h # Disk space
free -h # Memory usage (Linux)
top # Running processes (Ctrl+C to exit)
Keyboard shortcuts
These work in most terminals and will save you a lot of time:
| Shortcut | What it does |
|---|---|
| Tab | Autocomplete file/folder names |
| ↑ / ↓ | Previous / next command from history |
| Ctrl+C | Cancel current command |
| Ctrl+L | Clear the screen |
| Ctrl+A | Jump to beginning of line |
| Ctrl+E | Jump to end of line |
| Ctrl+R | Search command history |
Tab completion is the most important one. Start typing a filename and press Tab — the terminal fills in the rest.
Pipes and redirection
This is where the terminal gets powerful — combining commands:
# Pipe: send output of one command to another
ls | grep ".js" # List only .js files
cat log.txt | grep "error" | wc -l # Count error lines
# Redirect output to a file
echo "hello" > file.txt # Write (overwrites)
echo "world" >> file.txt # Append
# Redirect errors
command 2> errors.txt # Save errors to file
command > output.txt 2>&1 # Save everything to file
Installing things
# macOS (Homebrew)
brew install node
brew install git
# Ubuntu/Debian
sudo apt update
sudo apt install nodejs
# Any OS (Node.js packages)
npm install -g typescript
See: Homebrew cheat sheet for macOS package management.
Next steps
- Open your terminal right now
- Type
pwdto see where you are - Type
lsto see what’s there - Navigate to a project folder with
cd - Check out the Linux Terminal cheat sheet and Bash cheat sheet for more commands