Back to docs
02Week 1

Terminal Basics

Navigate, create, and manage your project from the command line

Opening the Terminal

PlatformHow to Open
macOSSpotlight → type “Terminal” → Enter
macOS (better)Install iTerm2 — more features, better experience
WindowsInstall WSL2 — gives you a real Linux terminal inside Windows
VS CodePress Ctrl + ` to toggle the built-in terminal

The Prompt

When you open the terminal, you see a prompt — a line of text ending with $ or %. This is where you type commands. The prompt usually shows your username, computer name, and current directory.

username@computer ~ %

The ~ symbol means your home directory. Everything you type after the prompt is a command.

Navigation Commands

CommandWhat It DoesExample
pwdPrint working directory — shows where you arepwd/Users/you/projects
lsList files and folders in current directoryls
ls -laList all files including hidden ones, with detailsls -la
cd folderChange directory — move into a foldercd my-project
cd ..Go up one levelcd ..
cd ~Go to home directorycd ~
cd -Go to the previous directory you were incd -

Navigation Practice

# See where you are
pwd

# List what's here
ls

# Move into a folder
cd Desktop

# Confirm you moved
pwd

# Go back up
cd ..

# Go home
cd ~

File and Folder Operations

CommandWhat It DoesExample
mkdirCreate a new foldermkdir my-project
mkdir -pCreate nested folders in one commandmkdir -p src/components/ui
touchCreate a new empty filetouch index.tsx
rmRemove a filerm old-file.txt
rm -rfRemove a folder and everything inside itrm -rf node_modules
cpCopy a filecp file.txt backup.txt
mvMove or rename a filemv old.txt new.txt
catDisplay file contents in terminalcat package.json
code .Open current folder in VS Codecode .
open .Open current folder in Finder (macOS)open .

Warning: rm -rf is permanent. There is no trash, no undo. Double-check the path before running this command.

Running Programs

CommandWhat It Does
nodeRun a JavaScript file — node script.js
npm installInstall all dependencies listed in package.json
npm run devStart the development server (Next.js)
npm run buildBuild the project for production
npxRun a package without installing it globally — npx create-next-app
Ctrl + CStop the currently running program
Ctrl + ZSuspend the currently running program

Productivity Shortcuts

ShortcutWhat It Does
TabAuto-complete file and folder names
↑ / ↓Scroll through previous commands
Ctrl + CCancel current command / stop running process
Ctrl + LClear the terminal screen
Ctrl + AJump to beginning of line
Ctrl + EJump to end of line
Ctrl + WDelete the word before cursor
!!Repeat the last command
historyShow all recent commands

Complete Project Setup Workflow

# 1. Go to your projects folder
cd ~/projects

# 2. Create a new Next.js app
npx create-next-app@latest my-portfolio

# 3. Move into the project
cd my-portfolio

# 4. Open in VS Code
code .

# 5. Start the dev server
npm run dev

# 6. Open in browser
# Visit http://localhost:3000

Understanding Paths

There are two kinds of paths:

Absolute Paths

Start from the root of your system. Always begin with /.

/Users/you/projects/my-app/src/components/Button.tsx

Relative Paths

Start from where you are right now.

# If you're in /Users/you/projects/my-app
cd src/components
# Now you're in /Users/you/projects/my-app/src/components

# Go up two levels
cd ../..
# Back to /Users/you/projects/my-app

Common Errors and Fixes

ErrorWhat It MeansHow to Fix
command not foundThe program isn’t installed or not in your PATHInstall it — e.g. brew install node
No such file or directoryThe path is wrong or the file doesn’t existCheck spelling, run ls to see what’s there
Permission deniedYou don’t have access to run thisTry sudo before the command (use with caution)
Port already in useAnother process is using port 3000Kill it with lsof -i :3000 then kill -9 PID
EACCESnpm permission errorFix npm permissions or use nvm