← Back to Course

Module -05

Terminal & Command Line

Every operating system has a text-based interface for power users. Understanding basic commands demystifies npm, git, and the tools modern web development requires.

From teletype machines to modern terminals. Mac has Terminal, Windows has PowerShell, Linux has Bash. VS Code integrates them all into one familiar interface.

GUI tools for everything, but CLI remains essential for automation, scripting, and developer workflows. AI assistants now help write commands too.

Commands are just programs. Arguments modify behavior. Paths describe locations. These concepts work the same across all operating systems.

Part A

Core Concepts

01

What is the Terminal?

Before graphical interfaces, computers only had text. The terminal is that text interface — still essential for developers because it's faster, scriptable, and universal.

user@computer
~ $ ls
Documents Downloads Desktop Pictures
~ $ cd Documents
~/Documents $ _|
You type commands, computer responds with text
A Text-Based Computer Interface

The terminal is a text interface to your computer. Instead of clicking icons, you type commands. It's faster for many tasks, and some things (like npm, git) require it.

⊞
macOS
Terminal, iTerm2, Warp
⊞
Windows
PowerShell, Command Prompt, Windows Terminal
⊞
Linux
GNOME Terminal, Konsole, Bash
VS
VS Code (All platforms)
Integrated terminal — same experience everywhere
Every OS Has One

Mac, Windows, Linux, and Chromebooks all have terminal applications. VS Code includes a built-in terminal that works identically across all platforms — use this for consistency.

TERMINAL
The window/app that displays text
Examples: Terminal.app, iTerm2, Windows Terminal
SHELL
The program that interprets commands
Examples: Bash, Zsh, PowerShell, Fish
Analogy: Terminal is the TV, Shell is the channel. Same TV can show different channels.
Terminal vs Shell

The terminal is the application (the window). The shell is the program running inside it that interprets your commands. Mac defaults to Zsh, Windows to PowerShell. Most basic commands work in all shells.

Speed: Type faster than click through menus
Automation: Script repetitive tasks
Required: npm, git, and many tools are CLI-only
Remote: Server management is all terminal
Universal: Same commands work everywhere
Why Use Command Line?

You don't need to become a terminal expert. But basic literacy lets you run npm commands, use git, and follow tutorials that assume command line knowledge.

02

Navigation Commands

The most essential skill: knowing where you are and moving between folders. These commands work on Mac, Linux, and (mostly) Windows.

03

Common Commands

Beyond navigation, these commands handle files, run programs, and get help. You'll use these daily when working with web projects.

# Create
mkdir new-folder # make directory
touch file.txt # create empty file

# Copy & Move
cp file.txt copy.txt # copy file
mv file.txt folder/ # move file
mv old.txt new.txt # rename file

# Delete (careful!)
rm file.txt # delete file
rm -rf folder/ # delete folder + contents
Creating, Copying, Moving, Deleting

mkdir makes folders, touch creates files, cp copies, mv moves (or renames), rm deletes. Warning: rm has no trash — deleted files are gone forever.

npm init # create package.json
npm install # install dependencies
npm install lodash # add a package
npm run dev # run 'dev' script
npm run build # run 'build' script
package.json defines what scripts exist. Check "scripts" section to see available commands.
Node Package Manager

npm (Node Package Manager) installs JavaScript libraries and runs project scripts. npm install reads package.json and downloads everything. npm run [script] runs predefined commands.

git clone [url] # download repository
git status # see what's changed
git add . # stage all changes
git commit -m "msg" # save snapshot
git push # upload to remote
git pull # download latest
VS Code has built-in git UI. Use that if CLI feels overwhelming at first.
Version Control Commands

git tracks file changes and syncs with GitHub/GitLab. The basic workflow: git add (stage changes) → git commit (save snapshot) → git push (upload).

command --help # show help
man command # manual page (Mac/Linux)
tldr command # simplified examples
Best resource: Ask AI "How do I [task] in terminal?" — get exact commands with explanations.
How to Learn More

Every command has built-in help via --help flag. man shows detailed manuals. Or just ask AI — it's excellent at explaining terminal commands with examples.

04

Practical Workflow

Real scenarios you'll encounter: opening projects, running servers, and handling common situations.

# Clone from GitHub
git clone https://github.com/user/repo.git
cd repo

# Install dependencies
npm install

# Start development server
npm run dev

# Open in browser: http://localhost:3000
Starting a New Project

Most projects follow this pattern: clone the repo, install dependencies with npm, run the dev server. The project's README usually explains the exact commands.

code .
Opens current folder in VS Code
code ~/Documents/project
Opens specific folder
code index.html
Opens specific file
Setup: In VS Code, press Cmd+Shift+P → "Shell Command: Install 'code' command"
Opening Folders in VS Code

code . opens the current folder in VS Code. The dot means "here". This is faster than File → Open Folder. Must be set up first via VS Code's command palette.

# Stop current command
Ctrl + C # Cancel/stop (works everywhere)

# If something's stuck on a port
lsof -i :3000 # find what's using port 3000
kill -9 [PID] # force stop that process

# Or just restart terminal
Ctrl+C is your friend. Use it to stop running servers, cancel commands, or escape situations.
Stopping Running Processes

Ctrl+C stops almost anything. If a dev server won't start because "port already in use", find the process with lsof and kill it, or just restart your terminal.

clear # clear screen (or Cmd+K)
history # show command history
↑ / ↓ # navigate previous commands
Ctrl + R # search command history
!! # repeat last command
sudo !! # repeat last as admin
Terminal Housekeeping

clear cleans your screen. Arrow keys navigate command history. Ctrl+R lets you search previous commands. These small efficiencies add up.

Key Takeaways

Every OS has a terminal
Mac
Terminal
Windows
PowerShell
All
VS Code

Mac has Terminal, Windows has PowerShell/Command Prompt, Linux has Bash. VS Code's integrated terminal works the same everywhere — use that for consistency.

Three essential commands
pwd # where am I
ls # what's here
cd # go somewhere

pwd shows your location, ls lists contents, cd moves between folders. Tab autocompletes. These three commands cover 80% of navigation.

npm and git basics
npm install
npm run dev
git status

npm install downloads dependencies. npm run dev starts local servers. git status shows what's changed. These commands run most web projects.

Ctrl+C is your friend
Ctrl + C

Ctrl+C stops almost any running command. Use it to exit stuck processes, cancel operations, or escape situations. Universal across all terminals.