Git & Command Line•20 min read•Beginner
The Terminal — Your First 10 Commands
Stop being scared of the black screen. Master cd, ls, mkdir, mv, cp, rm in 20 minutes.
Why the terminal?
The terminal (a.k.a. shell, command line, console, bash, zsh) is the fastest way to interact with a computer once you know it. Every professional engineer is fluent here. The good news: you only need ~15 commands to be useful, and the rest is google-when-you-need-it.
🚗
Real-life analogy — Mouse vs terminal
The mouse is automatic transmission — easy, slow, fine for most things. The terminal is manual transmission — steep learning curve, then suddenly faster than the mouse for almost every task. Plus, the only way to drive a remote server (no GUI on a Linux box in a data center).
Where am I, and what's here?
bash
pwd # print working directory: shows where you are
ls # list files in current directory
ls -l # long format: permissions, size, date
ls -la # also show hidden files (those starting with .)
ls -lh # human-readable file sizes (4.2K, not 4231)Moving around
bash
cd projects # change directory into 'projects'
cd .. # go up one level
cd # go to your home directory (~)
cd /etc # absolute path — always works regardless of where you are
cd - # go to the previous directory (handy!)Working with files & folders
bash
mkdir my-app # make a directory
mkdir -p src/components/ui # make nested directories
touch README.md # create an empty file (also: updates timestamp)
cp old.txt new.txt # copy
cp -r src/ src-backup/ # -r for recursive (folders)
mv draft.txt final.txt # move OR rename
rm temp.log # remove a file
rm -rf node_modules/ # remove a folder and EVERYTHING in it (DANGEROUS)⚠ Watch out
The terminal has NO Recycle Bin. `rm -rf` deletes files instantly and permanently. ALWAYS read the path twice before pressing Enter, especially with sudo.
Reading file contents
bash
cat README.md # print the whole file
less big.log # scrollable view (q to quit)
head -n 20 server.log # first 20 lines
tail -n 50 server.log # last 50 lines
tail -f server.log # FOLLOW — keep printing as the file grows💡 Tip
Press Tab to autocomplete file names and commands. Press up-arrow to scroll through your command history. These two habits triple your terminal speed.