1. Command Line Without Fear
Command Line & Shell Essentials
Conquer terminal fear: learn how directories work, navigate with pwd/cd/ls, create/copy/move files safely, search code with grep, and chain commands with pipes.
- Navigate directories comfortably using pwd, ls, and cd
- Create, copy, move, and inspect files from the command line
- Search text across folders with grep and chain commands with pipes
Many beginners avoid the terminal because a blinking cursor feels unforgiving. In reality, the terminal is just a fast, text-based way to do the exact same things you already do in Finder or Windows Explorer—opening folders, creating files, and running apps.
Think of the terminal like talking directly to your computer instead of clicking icons with a mouse. Once you learn about 10 everyday commands, you can navigate projects in seconds.
Where Am I? (pwd, ls, cd)
When you open Finder or File Explorer, you are always looking inside one folder at a time. The terminal works the exact same way—your blinking cursor is always "standing" inside a single current folder.
Use these three commands to check where you are, look around, and walk into another folder:
pwd # Print Working Directory (shows your full folder path)
ls # List visible files and folders right here
ls -la # List ALL files, including hidden files like .gitignore
cd projects/site # Change Directory into projects/site
cd .. # Walk up one parent folder
cd ~ # Jump straight back to your home folderNotice the little -la flag on ls -la: in terminal commands, flags starting with - customize how a command behaves (-l shows details like file size and date, and -a reveals hidden dotfiles starting with .).
Type the first 2–3 letters of a file or folder and press Tab—your shell autocompletes the rest! And press the Up Arrow to recall previous commands without retyping.
Creating, Copying, Moving & Deleting Files
Right-clicking to create folders one by one gets slow when setting up a real coding project. In the terminal, a single line can build nested folders or copy files cleanly.
mkdir -p src/components # Create nested folders cleanly (-p creates parents too)
touch README.md # Create an empty file named README.md
cp README.md README.bak # Copy README.md to README.bak
mv README.bak docs/ # Move README.bak into the docs/ folderYou can also use mv to rename a file—for example, mv old.txt new.txt moves it to the new name in the same folder.
Unlike dragging a file to the Trash, rm filename deletes immediately without a Recycle Bin! Always check pwd and ls before running rm or rm -rf.
Reading & Searching Text (cat, head, grep)
Sometimes you don't want to open a whole code editor just to peek inside a file or hunt down where a function lives across 50 files.
cat package.json # Print the entire file right in your terminal
head -n 15 package.json # Show only the first 15 lines
grep -rn "Quiz" src/ # Search recursively inside src/ for "Quiz"In grep -rn, -r means recursive (check every subfolder too) and -n prints the exact line number where each match lives.
Chaining Tools with Pipes (|) and Redirects (>)
One of the coolest ideas in the terminal is connecting small commands together like Lego bricks using the pipe (|):
|takes the text output of the command on the left and feeds it straight into the command on the right.>saves command output into a file (overwriting it), while>>appends cleanly to the bottom.
ls -la | grep ".mdx" # List all files, then keep only lines containing .mdx
echo "Study Note 1" > notes.txt
echo "Study Note 2" >> notes.txtNotice how ls -la | grep ".mdx" reads almost like English: "List everything here, then filter down to .mdx files."
Quick Checkpoints
What does cd .. do in the terminal?
Which command searches recursively inside src/ for fetchUser and displays line numbers?