Terminal Basics

The terminal (also called command line, shell, or console) is a text-based way to control your computer. You'll use it constantly in development.

Opening the Terminal

OS How to Open
Windows Search "PowerShell" or "Command Prompt" — or use WSL2
macOS Applications → Utilities → Terminal, or Cmd+Space and type "Terminal"
Linux Ctrl+Alt+T or search "Terminal"

Where Am I? (pwd)

pwd stands for "print working directory" — it shows your current folder.

pwd
# → /home/yourname/projects

What's Here? (ls)

List files and folders in the current directory.

ls
# → Documents  Downloads  Music  Pictures

ls -la    # More details: hidden files, permissions, sizes

Move Around (cd)

cd means "change directory."

cd Documents       # Go into Documents
cd ..              # Go up one folder
cd ~               # Go to your home folder
cd /               # Go to the root of your filesystem
cd -               # Go back to where you were

Make Folders (mkdir)

mkdir my-project           # Create one folder
mkdir -p app/backend/app   # Create nested folders (no error if they exist)

Create Files (touch)

touch file.txt        # Create an empty file
touch app.py README.md  # Create multiple files

Copy, Move, Delete

cp file.txt backup.txt           # Copy file
cp -r folder/ backup-folder/     # Copy entire folder

mv file.txt newname.txt          # Rename a file
mv file.txt Documents/           # Move a file into a folder

rm file.txt                      # Delete a file (permanent — no trash!)
rm -rf folder/                   # Delete a folder and everything in it

Warning: rm -rf is permanent. There is no undo. Double-check before pressing Enter.

View File Contents

cat file.txt          # Print entire file in terminal
less file.txt         # View file page by page (press q to quit)
head -n 10 file.txt   # First 10 lines
tail -n 10 file.txt   # Last 10 lines

Redirection and Pipes

echo "Hello" > file.txt      # Write "Hello" to file.txt (overwrites)
echo "World" >> file.txt     # Append "World" to file.txt

# Pipe: send output of one command to another
ls -la | grep "txt"          # List files, filter to those with "txt"
cat file.txt | wc -l         # Count lines in file.txt

Running Python Scripts

python3 script.py        # Run a Python script
python3 script.py arg1   # Pass an argument

Common Shortcuts

Key Action
Ctrl+C Cancel current command
Ctrl+D Exit terminal session
Up arrow Previous command
Tab Auto-complete file/folder names
Ctrl+L Clear the screen

Your Turn — Mini Exercise

Open your terminal and try:

mkdir -p /tmp/my-test
cd /tmp/my-test
touch hello.txt world.txt
ls -la
echo "Hello terminal!" > hello.txt
cat hello.txt
cp hello.txt hello-copy.txt
rm hello-copy.txt
ls -la
cd ..
rm -rf my-test