π» Mastering the Terminal (Windows, Mac, Linux)
π― Lesson Objectives
By the end of this lesson, learners will be able to:
- Understand what the terminal is and how it differs across platforms.
- Navigate directories using standard commands.
- Create, view, copy, move, rename, and delete files and folders using the CLI.
β¨οΈ What is the Terminal?
The terminal (also called the command line) allows you to interact with your computer using text commands instead of a mouse.
Developers use the terminal to:
- Manage files and folders efficiently.
- Run programs and automated scripts.
- Use version control (Git).
- Control development servers and tools.
π‘οΈ One Language, Many Platforms
In modern software engineering, the Terminal is the universal language. However, how you access it depends on your operating system:
- Mac Users: macOS is built on a Unix foundation; your native Terminal app supports these commands natively.
- Linux Users: This is your natural environment.
- Windows Users: This is critical. Standard Windows tools like "Command Prompt" (CMD) or "PowerShell" follow different rules. To run these standard developer commands on Windows, you must use a compatibility tool like Git Bash or the Windows Subsystem for Linux (WSL).
π Understanding Directories
A directory is simply another name for a folder. The terminal lets you move between directories and manage whatβs inside them.
The Shell Prompt
Every line starts with a prompt, giving you context:
dev@machine:~/projects$
dev: The current user.~: Shortcut for your Home Directory.$: Indicates you are a standard user.
π Essential Commands
π pwd β Print Working Directory
Shows the folder you are currently inside.
pwd
π ls β List Files and Folders
Shows the contents of the current directory.
ls
Useful Flags
ls -a: Shows hidden files (files starting with a.).ls -l: Shows a detailed list (size, date, permissions).ls -la: Combines bothβshows hidden files in a detailed view.
π cd β Change Directory
- Move into a folder:
cd projects - Move back one level:
cd .. - Go to home directory:
cd ~
π§Ή clear β Clear the Screen
Removes previous commands from view (start with a fresh slate).
clear
π mkdir & touch β Create Things
mkdir website: Creates a new folder.touch index.html: Creates an empty file.
π£οΈ echo β Print and Write Content
1οΈβ£ Print Text
echo Hello World
2οΈβ£ Create or Overwrite (>)
Using > writes text into a file. If the file exists, it replaces everything inside.
echo "My first webpage" > index.html
3οΈβ£ Append Content (>>)
Using >> adds text to the end of a file without deleting what is already inside.
echo "This line was added later" >> index.html
| Command | What It Does |
|---|---|
echo "text" > file.txt | Creates or overwrites existing content |
echo "text" >> file.txt | Appends text to the end of the file |
π cat β View and Create Content
- View:
cat index.html(Displays what is inside). - Create/Overwrite:
cat > notes.txt(Type content, then press CTRL+D to save). - Append:
cat >> notes.txt(Add content, press CTRL+D to save).
π cp & mv β Copy and Move
- Copy File:
cp index.html about.html - Copy Folder:
cp -r website backup-website(The-ris required for folders). - Rename/Move:
mv index.html home.html
β rm & rmdir β Delete
- Delete Empty Folder:
rmdir old-folder - Delete File:
rm file.txt - Delete Folder & Content:
rm -r website
β οΈ CAUTION: Deletions are instantaneous and permanent. There is no Recycle Bin.
π§ͺ Practice Exercise
Try the following commands step by step:
mkdir web-practice
cd web-practice
touch index.html
echo "Hello Web" > index.html
echo "Learning terminal commands" >> index.html
cat index.html
mkdir assets
cp index.html assets/
ls -l
πΌοΈ Terminal Example

π₯ Lesson Video
<video controls width="100%"> <source src="/videos/lesson-3-terminal-basics.mp4" type="video/mp4"> Your browser does not support the video tag. </video>π Project Task: Terminal Mastery
Using only the terminal:
- Create a folder named
my-first-website - Inside it, create
index.htmlandabout.html. - Add the text "Welcome to my website" inside
index.htmlusingecho. - Append another line to
index.htmlusingecho >>. - Create a file called
notes.txtusingcatand write two lines inside. - Append a third line to
notes.txtusingcat >>. - Copy
index.htmlinto a new folder calledbackup. - Rename
about.htmltoabout-me.html. - Verify your folder structure using
ls -l.