⌨️ Command Line Interface (CLI) Tutorial
Every professional developer lives in the terminal. It looks intimidating — a blinking cursor on a blank screen — but it's really just a faster, more precise way to tell your computer what to do. Learn a dozen commands here and you'll move through your file system quicker than any mouse ever could.
Reference & Extra Tutorials · Resources · Toolbelt Essentials
🎯 What This Covers
By the end of this reference, you will be able to:
- Open a terminal on macOS, Linux, Windows, and WSL, and read a shell prompt
- Find out where you are and move between directories with
pwdandcd - List, create, and inspect files and folders
- Copy, move, rename, and delete files safely — and know which deletions are irreversible
- Search for files with
findand get help on any command - Chain a real workflow: scaffold a small project folder from scratch
Estimated Time: 45 minutes
Practice: Build a project folder tree entirely from the command line.
In This Tutorial
What Is the CLI?
A Command Line Interface is a text-based conversation with your computer. Instead of pointing and clicking, you type a command, press Enter, and the machine carries it out. Think of it like the difference between a menu of pictures at a fast-food kiosk and simply telling a chef exactly what you want: the kiosk is friendlier for beginners, but the direct request is faster and far more precise once you know the words.
The program that reads your commands is called a shell. Common shells are bash and zsh on macOS/Linux, and PowerShell on Windows. The window the shell runs in is the terminal. People say "terminal," "command line," "shell," and "console" almost interchangeably.
Why bother, when a graphical file manager exists? Because the CLI is fast, scriptable, and universal. Servers usually have no desktop at all — the command line is the only way in. Git, Node, npm, and Docker are all driven from the terminal. Learning it now pays off in every lesson that follows.
💡 One prompt, many machines
The blinking prompt often ends in $ (regular user) or # (administrator/root). When a tutorial shows $ ls, the $ just represents the prompt — you type only ls.
Opening a Terminal
Wherever you are, there's a terminal one shortcut away.
| System | How to open it | Default shell |
|---|---|---|
| macOS | ⌘ + Space, type "Terminal", Enter | zsh |
| Linux | Ctrl + Alt + T (most desktops) | bash |
| Windows | Start menu → "Windows Terminal" or "PowerShell" | PowerShell |
| WSL (Windows) | Start menu → "Ubuntu" (or your distro) | bash |
This bootcamp assumes a Unix-style shell (macOS, Linux, or WSL on Windows). The commands below are the Unix ones; where Windows PowerShell differs, we note the alternative. If you're on Windows, installing WSL gives you a real Linux command line and is strongly recommended — nearly every backend tool assumes it.
# Check which shell you're running
echo "$SHELL"
# Common output: /bin/zsh or /bin/bash
Creating & Removing Folders
Making a new folder is like adding a room to the house.
Make a directory: mkdir
mkdir my-project # one new folder
mkdir docs images styles # three folders at once
mkdir -p src/components/ui # -p creates the whole nested path in one go
The -p ("parents") flag is a favorite: it builds every folder in the path that doesn't yet exist, instead of failing because src isn't there.
Remove an empty directory: rmdir
rmdir old-folder # only works if the folder is EMPTY
rmdir is deliberately picky — it refuses to delete a folder that still has anything inside. That's a safety feature. To delete a folder and its contents, see the recursive delete in the next section.
Creating & Deleting Files
Create an empty file: touch
touch notes.txt # create an empty file
touch index.html style.css # create several at once
touch was originally built to update a file's timestamp, but its handy side effect — creating the file if it doesn't exist — is what everyone uses it for. On PowerShell, use New-Item notes.txt instead.
Delete a file: rm
rm notes.txt # delete one file
rm a.txt b.txt c.txt # delete several
⚠️ There is no undo
rm does not move files to a Recycle Bin or Trash — it deletes them permanently and immediately. Read the filename twice before you press Enter, and be extremely careful with wildcards like rm *.txt.
Delete a folder and everything in it: rm -r
rm -r old-project # -r = recursive: folder + all contents
rm -ri old-project # -i asks you to confirm each deletion (safer)
Adding -i ("interactive") makes the command ask for confirmation on each item — a good habit while you're learning. Never run rm -rf / or paste a destructive command you don't understand; that pattern can wipe an entire system.
Moving, Renaming & Copying
Move & rename: mv
mv ("move") does double duty — it relocates a file, and it renames one, because renaming is really just "move to the same folder under a new name."
# Move a file into a folder
mv report.txt documents/
# Rename a file (move it to a new name in the same place)
mv report.txt final-report.txt
# Move AND rename in one step
mv report.txt archive/2026-report.txt
Copy: cp
cp ("copy") makes a duplicate — the original stays put, like using a photocopier.
cp report.txt backup.txt # copy a file
cp report.txt documents/ # copy a file into a folder
cp -r templates/ new-project/ # -r copies a whole folder tree
Just like with delete, copying a folder needs the recursive -r flag so the command descends into every sub-folder.
The key difference: mv leaves nothing behind, while cp leaves the original in place.
Searching & Getting Help
Find files: find
find walks through a directory and everything inside it, looking for matches.
# Find a file by exact name, starting from the current directory (.)
find . -name "notes.txt"
# Find every JavaScript file below here (quotes protect the wildcard)
find . -name "*.js"
# Find only directories named "node_modules"
find . -type d -name "node_modules"
The . means "start here"; -name matches the filename; -type d restricts the search to directories (use -type f for files).
Get help on any command
You never have to memorize every flag. Two reliable ways to look things up:
cp --help # a quick summary of options
man cp # the full manual page (press q to quit)
On PowerShell the equivalent is Get-Help Copy-Item. Reading --help before running an unfamiliar command is a professional habit worth building early.
💡 Handy keyboard tricks
- Tab — auto-complete a file or folder name
- ↑ / ↓ — scroll through your command history
- Ctrl + C — cancel the command that's running
- Ctrl + L — clear the screen (same as
clear) history— print every command you've run recently
Command Cheat Sheet
Keep this table within reach. These fifteen commands cover the vast majority of daily terminal work.
| Command | What it does | Example |
|---|---|---|
pwd | Print working directory | pwd |
ls | List directory contents | ls -la |
cd | Change directory | cd ../src |
mkdir | Make a directory | mkdir -p a/b/c |
rmdir | Remove an empty directory | rmdir old |
touch | Create an empty file | touch app.js |
rm | Delete a file | rm temp.txt |
rm -r | Delete a folder + contents | rm -r build/ |
mv | Move or rename | mv a.txt b.txt |
cp | Copy a file | cp a.txt bak.txt |
cp -r | Copy a folder tree | cp -r src/ dist/ |
find | Search for files | find . -name "*.js" |
cat | Print a file's contents | cat notes.txt |
echo | Print text / a variable | echo "$PATH" |
clear | Clear the screen | clear |
Practice & Quiz
🏋️ Exercise 1: Scaffold a project by hand
Goal: Starting from your home directory, build this exact tree using only the terminal, then confirm it exists:
my-site/
├── index.html
├── css/
│ └── style.css
└── js/
└── app.js
💡 Hint
Create my-site and cd into it first. Use mkdir for the two folders and touch for the three files. Verify with ls -R (recursive list) or find ..
✅ Solution
cd ~
mkdir my-site
cd my-site
mkdir css js
touch index.html css/style.css js/app.js
# Confirm the tree
ls -R
# .:
# css index.html js
# ./css:
# style.css
# ./js:
# app.js
🏋️ Exercise 2: Reorganize safely
Goal: Rename index.html to home.html, make a backup/ folder, and place a copy of home.html inside it — without losing the original.
✅ Solution
mv index.html home.html # rename
mkdir backup # new folder
cp home.html backup/ # copy (original stays put)
ls backup/ # home.html
🎯 Quick Quiz
Question 1: Which command tells you the full path of the folder you're currently in?
Question 2: You want to delete a folder that still has files inside it. Which works?
Question 3: What's the difference between mv and cp?
Best Practices & Pitfalls
✅ Do
- Use Tab completion constantly — it's faster and prevents typos
- Run
pwdandlsto orient yourself before any destructive command - Quote filenames that contain spaces:
cd "My Documents" - Add
-itormwhile you're learning, so it asks before deleting - Read
command --helpbefore running something unfamiliar
❌ Don't
- Run
rm -rfon a path you haven't double-checked — there is no Trash to recover from - Paste commands from the internet without understanding what they do
- Assume wildcards are harmless —
rm *deletes everything in the folder - Fight the terminal on Windows with plain Command Prompt; install WSL for a real Unix shell
⚠️ The wildcard trap
# Intended: delete temp files
rm temp *.log
# Oops — the accidental space means "delete a file named temp
# AND every .log file." Wildcards expand BEFORE rm runs.
When a command is destructive, preview the wildcard first with ls *.log to see exactly what it will match.
Summary
🎉 Key Takeaways
- The CLI is a fast, precise, scriptable way to command your computer — and the only way onto most servers
pwd,ls, andcdare how you orient and navigate the file treemkdir,touch,rm,mv, andcpcreate, delete, and move files and folders- Recursive flags (
-r) make commands descend into folders;rmdeletes permanently - Tab completion and
--helpare your two most valuable habits
📚 Additional Resources
- Ubuntu — The Linux command line for beginners
- MDN — Command line crash course
- Microsoft — Install WSL on Windows
🚀 What's Next?
Now that you can move through the file system confidently, you're ready to put a real tool on top of it. Next up: Docker with Express and SQLite3, where you'll use these exact commands to build, run, and package a containerized web application.
🎉 You speak terminal now!
Every backend tool in this course — Git, Node, npm, Docker — is driven from the command line you just learned. This is the foundation the rest of the stack sits on.