How-To Guide
Command Line Basics for Beginners
The terminal isn't scary. Once you learn 10 commands, you'll use it every day. Here's everything a beginner needs to know.
💡 Why Learn the Command Line?
Modern developers live in the terminal. Reasons why it matters:
- Faster than clicking: Creating 20 folders takes 1 second in the terminal
- Required for tools: Git, npm, Python, and Docker all run in the terminal
- Automate tasks: Rename 500 files at once or deploy a website with 3 commands
- Works everywhere: Same skills on Mac, Linux, and (mostly) Windows
- Employers expect it: Every developer job assumes basic terminal fluency
📋 What You'll Need
- A computer running Windows, macOS, or Linux
- The terminal app that comes pre-installed on your OS
- About 15 minutes to practice
✅ Nothing to install. The terminal is already on your computer.
Open the Terminal
Different operating systems use different names:
- Windows: Press
Win + R, typecmd, hit Enter (Command Prompt). Or search for PowerShell in the Start menu. - Mac: Press
Cmd + Space, type "Terminal", hit Enter. - Linux: Press
Ctrl + Alt + T.
A black (or white) window will appear with a blinking cursor. That's the terminal.
💡 Command Prompt vs PowerShell (Windows): PowerShell is the modern version with more features. Either works for this guide. Commands below marked with [PS] work in PowerShell.
Where Am I? (pwd / cd)
Before you do anything, know where you are in the file system.
Mac / Linux:
pwd
Output example: /Users/alex/Documents
Windows:
cd
Output example: C:\Users\Alex\Documents
The output tells you which folder you're currently in. All commands you run will affect this folder.
What's Here? (ls / dir)
List the files and folders in your current directory.
Mac / Linux:
ls
For a detailed list (size, date, permissions):
ls -la
Windows:
dir
Output example:
Documents Downloads Desktop Music
Navigate Folders (cd)
cd stands for "change directory". This is your most-used command.
Go into a folder:
cd Documents
Go back up one level:
cd ..
Go to your home folder:
cd ~ # Mac/Linux
cd %USERPROFILE% # Windows
Jump between drives (Windows):
D:
Switches from C: to D: drive.
💡 Tip: Type the first few letters of a folder and press Tab to auto-complete the name. This saves tons of time and avoids typos.
Create Folders and Files
Create a folder:
mkdir my-project
Works on all operating systems. "mkdir" = "make directory".
Create an empty file (Mac/Linux):
touch index.html
Create an empty file (Windows):
type nul > index.html
Or with PowerShell:
New-Item index.html
Delete a file:
rm filename.txt # Mac/Linux
del filename.txt # Windows
Delete an empty folder:
rmdir folder-name # Mac/Linux
rmdir folder-name # Windows
⚠️ Be careful with rm: Deleted files via the terminal do NOT go to the recycle bin. They're gone immediately. Double-check filenames before hitting Enter.
Move and Copy Files
Copy a file:
cp file.txt backup.txt # Mac/Linux
copy file.txt backup.txt # Windows
Move or rename a file:
mv old.txt new.txt # Mac/Linux (rename)
mv file.txt ../ # Mac/Linux (move up one folder)
move old.txt new.txt # Windows
move file.txt ..\ # Windows
Note: On Mac/Linux, mv does both "move" and "rename" — the same command, different context.
Run Programs and Scripts
The terminal lets you run any program installed on your system:
Run Python:
python hello.py
Run Node.js:
node app.js
Run Git commands:
git status
git commit -m "First commit"
Run npm commands:
npm install express
npm run start
Any program whose folder is in your system PATH can be run just by typing its name.
Stop a Running Command
Sometimes a command runs forever (like a local server). To stop it:
Ctrl + C
This sends an "interrupt" signal to the program and returns you to the prompt. This is the most important shortcut to remember.
📋 Command Cheat Sheet
Bookmark this — you'll use it constantly.
| What you want to do | Mac / Linux | Windows |
|---|---|---|
| Show current folder | pwd | cd |
| List files here | ls | dir |
| Enter a folder | cd folder | cd folder |
| Go up one level | cd .. | cd .. |
| Go to home folder | cd ~ | cd %USERPROFILE% |
| Create a folder | mkdir name | mkdir name |
| Create a file | touch file.txt | type nul > file.txt |
| Delete a file | rm file.txt | del file.txt |
| Copy a file | cp a.txt b.txt | copy a.txt b.txt |
| Move / rename | mv a.txt b.txt | move a.txt b.txt |
| Clear the screen | clear | cls |
| Stop running command | Ctrl+C | Ctrl+C |
🎯 What's Next?
You've learned the terminal basics. Now build on this foundation.