Most beginner tutorials assume you already know what the terminal is. This one doesn't. By the end you'll be able to navigate your file system, create project folders, run programs, and read error messages β all without touching your mouse.
What is the terminal, and why do developers use it?
The terminal is a text-based interface to your computer. Instead of clicking icons and menus you type instructions and press Enter. The computer executes them immediately.
That sounds slower than clicking, but it isn't once you know the commands. A developer can:
- Create 10 nested folders in one command instead of clicking "New Folder" 10 times
- Install a library in 3 seconds with
npm installinstead of hunting through a GUI installer - Run the same sequence of steps every time with no mouse errors
- Connect to a remote server that has no screen at all
Everything in modern development β installing Node.js, running Git, starting a Next.js app β happens through the terminal. There is no way around it.
How to open the terminal
macOS
Option 1 β Spotlight (fastest):
- Press
Cmd + Space - Type
Terminal - Press
Enter
Option 2 β Finder:
Go to Applications β Utilities β Terminal
You'll see a window with a prompt that looks something like this:
yash@MacBook-Pro ~ %
That % (or $ on older Macs) means the terminal is ready for a command.
Windows
Windows has three options. Here's what each one is:
| Tool | What it is | Recommendation |
|---|---|---|
Command Prompt (cmd.exe) | Legacy shell, ships with Windows | Only use if nothing else available |
| PowerShell | Modern shell, ships with Windows | Good, use if you don't want to install anything |
| Windows Terminal | App from Microsoft Store that hosts PowerShell, cmd, and more in tabs | Recommended |
Install Windows Terminal (free, takes 2 minutes):
- Open the Microsoft Store
- Search for "Windows Terminal"
- Click Install
Once open, Windows Terminal starts PowerShell by default. All commands in this guide will work in PowerShell unless marked otherwise.
The mental model: your terminal always has a location
Before any command makes sense, understand this: the terminal is always "inside" a folder on your computer. That current location is called the working directory. Every command you run acts relative to where you currently are.
Core navigation commands
See where you are β pwd / cd with no arguments
Mac/Linux:
pwd
Output:
/Users/yash/Documents
Windows PowerShell:
cd
Output:
C:\Users\yash\Documents
pwd stands for "print working directory." It answers the question: where am I right now?
List what's in a folder β ls / dir
Mac/Linux:
ls
ls -la # show hidden files and file sizes too
Windows:
dir
ls # PowerShell also accepts ls as an alias for dir
Output (Mac example):
Desktop Documents Downloads Projects
Move into a folder β cd
cd Documents
cd Documents/Projects/my-app # jump multiple levels at once
cd .. # go up one level to the parent folder
cd ../.. # go up two levels
cd ~ # jump to your home folder (Mac/Linux)
cd $HOME # same thing on Windows PowerShell
Create a folder β mkdir
mkdir my-project
mkdir -p my-project/src/components # create nested folders in one go (Mac/Linux)
Windows PowerShell:
mkdir my-project
New-Item -ItemType Directory -Path "my-project\src\components" -Force
Create an empty file β touch / New-Item
Mac/Linux:
touch index.html
touch style.css script.js # create multiple files at once
Windows PowerShell:
New-Item index.html
Or the old cmd-style trick that still works in PowerShell:
type nul > index.html
Delete a file or folder β rm / del
Mac/Linux:
rm old-file.txt
rm -r old-folder # -r means recursive, needed to delete a folder
Windows PowerShell:
Remove-Item old-file.txt
Remove-Item old-folder -Recurse
Warning: rm on Mac/Linux does not move to Trash. The file is gone. Double-check before pressing Enter.
Copy a file β cp / Copy-Item
Mac/Linux:
cp source.txt destination.txt
cp -r source-folder/ destination-folder/ # copy a whole folder
Windows:
Copy-Item source.txt destination.txt
Copy-Item source-folder -Destination destination-folder -Recurse
Move or rename a file β mv / Move-Item
Mac/Linux:
mv old-name.txt new-name.txt # rename
mv file.txt Documents/ # move to a different folder
Windows:
Move-Item old-name.txt new-name.txt
Move-Item file.txt Documents\
Clear the screen β clear / cls
Mac/Linux:
clear
Windows:
cls
Or press Ctrl + L on both platforms.
Two time-saving shortcuts
Tab completion
Start typing a folder or file name and press Tab. The terminal auto-completes it.
cd Doc[TAB] # completes to: cd Documents
If there are multiple matches, press Tab twice to see them all. Use tab completion constantly β it prevents typos in paths.
Command history
Press the Up arrow key to scroll through previous commands. Press it repeatedly to go further back. Press Down to come forward. When you find the command you want, press Enter.
Running a script or program
Once you've installed a programming language or tool, you run it from the terminal.
Run a Python script:
python3 my_script.py
Run a Node.js file:
node app.js
Run a shell script:
bash setup.sh
The pattern is always: program filename. The terminal finds the program, hands it the file, and shows the output.
Reading error messages
Error messages look scary but they always tell you exactly what's wrong.
| Error | What it means | Fix |
|---|---|---|
command not found: node | The program isn't installed, or the terminal can't find it | Install the program; restart the terminal |
No such file or directory | The path you typed doesn't exist | Check spelling; run ls to see what's actually there |
Permission denied | You don't have rights to run or edit this file | On Mac/Linux, prefix with sudo (only if you know why) |
Is a directory | You used a file command on a folder | Add the -r flag, or switch to the folder-appropriate command |
ENOENT | Node.js version of "No such file or directory" | Same fix β check your path |
When you see an error, read the last line first. It's usually the clearest statement of what went wrong.
Shell, terminal, bash, zsh, PowerShell β what's the difference?
These words get mixed up constantly. Here's the short version:
| Term | What it is |
|---|---|
| Terminal | The app/window where you type (Terminal.app on Mac, Windows Terminal on Windows) |
| Shell | The program running inside the terminal that interprets your commands |
| bash | A shell. Was macOS default until 2019. Still default on most Linux servers |
| zsh | A shell. macOS default since Catalina (2019). Mostly the same as bash for everyday use |
| PowerShell | Microsoft's modern shell for Windows. Different syntax from bash/zsh |
| cmd.exe | Windows legacy shell. Avoid it for new work |
The terminal is the window. The shell is the engine inside it.
Hands-on exercise: build a project folder structure
Do this now. Open your terminal and run these commands exactly. By the end you'll have a real folder structure and you'll have used every command in this guide.
# 1. Go to your home folder
cd ~
# 2. Create a projects folder if you don't have one
mkdir projects
# 3. Enter it
cd projects
# 4. Create a new project folder
mkdir my-first-site
# 5. Enter the project
cd my-first-site
# 6. Create the folder structure
mkdir src
mkdir src/css
mkdir src/js
mkdir public
# 7. Create the main files
touch index.html
touch src/css/style.css
touch src/js/app.js
# 8. Confirm it all exists
ls -R
Expected output:
index.html public src
./public:
./src:
css js
./src/css:
style.css
./src/js:
app.js
Now rename the project:
cd .. # go up to projects/
mv my-first-site portfolio-site # rename the folder
cd portfolio-site # go back in
ls # confirm everything is still there
You just built and renamed a project using nothing but the terminal.
Mac vs Windows command reference
| Task | Mac / Linux | Windows PowerShell |
|---|---|---|
| Where am I? | pwd | cd |
| List files | ls or ls -la | dir or ls |
| Change folder | cd foldername | cd foldername |
| Go up one level | cd .. | cd .. |
| Create folder | mkdir name | mkdir name |
| Create file | touch file.txt | New-Item file.txt |
| Delete file | rm file.txt | Remove-Item file.txt |
| Delete folder | rm -r folder | Remove-Item folder -Recurse |
| Copy file | cp a.txt b.txt | Copy-Item a.txt b.txt |
| Move/rename | mv old new | Move-Item old new |
| Clear screen | clear or Ctrl+L | cls or Ctrl+L |
What to learn next
The terminal is the foundation. Once you're comfortable here, everything else builds on top:
- Git β version control you run entirely from the terminal. See the Git beginner guide.
- Node.js β JavaScript on your computer, installed and run through the terminal. See the Node.js beginner guide.
- Next.js β React framework you create and run with terminal commands. See the Next.js beginner guide.
- Python β same pattern: install it, run scripts with
python3 filename.py. See the Python beginner guide.
The terminal feels awkward for about a week. After that it feels faster than any GUI you've ever used.