Course:Internet & Tools/
Lesson

Before you can do anything useful in the terminalWhat is terminal?A text-based interface where you type commands to interact with your computer. Also called the command line or shell., you need to understand how to move around. Think of your computer's file system like a city. You have main streets (root directories), neighborhoods (folders), and buildings (files). Right now, you are somewhere in this city, but you need to know exactly where before you can navigate to your destination.

Knowing where you are: pwd

The most fundamental question in navigation is: "Where am I?" In the terminalWhat is terminal?A text-based interface where you type commands to interact with your computer. Also called the command line or shell., pwd answers that.

pwd
# Output: /Users/sarah/Documents

That is your absolute path: your exact coordinates in the file system. It starts from the root (/) and traces the complete route to your current location.

02

Seeing what is around you: ls

Once you know where you are, you want to see what is here. That is what ls does, it lists the contents of your current directory.

ls
# Output: Desktop  Documents  Downloads  Music  Pictures

Making ls more useful with flags

The basic ls is fine, but flags make it much more informative.

FlagWhat it doesWhy use it
-aShow all files, including hidden onesSee config files like .bashrc
-lLong format with detailsShows permissions, sizes, dates
-hHuman-readable sizesShows "1.5K" instead of "1536"
-laCombine both flagsEverything, with full details
ls -la
# drwxr-xr-x  12 sarah  staff   384B Jan 15 10:32 .
# drwxr-xr-x   5 sarah  staff   160B Jan 10 09:15 ..
# -rw-r--r--   1 sarah  staff   220B Jan 14 16:20 .bashrc
# drwxr-xr-x   8 sarah  staff   256B Jan 15 09:00 Documents

Files that start with a dot (.) are hidden by default. They are usually configuration files, .bashrc, .gitignore, .ssh/. The -a flag reveals them.

03

Moving between directories: cd

cd stands for "Change Directory." It is how you move from one folder to another.

cd Documents       # Enter a subdirectory
cd ..              # Go up one level
cd ~               # Go to home directory
cd -               # Go back to previous directory
cd ../..           # Go up two levels
AI pitfall
AI often gives you absolute paths like cd /Users/sarah/Documents/Projects/my-app when a simple cd ~/Projects/my-app or even cd Projects/my-app (relative) would work. It also forgets about spaces in filenames, you need quotes or backslashes: cd "My Documents" or cd My\ Documents. Without them, the shell treats each word as a separate argument.
04

Absolute vs relative paths

This is where many beginners get confused. Let us clear it up.

An absolute path always starts with / (the root). It works from anywhere because it specifies the complete route from the top. Think of it as a full postal address.

cd /Users/sarah/Documents/Projects/my-app
cd /var/log

A relative path does not start with /. It starts from your current location. Think of it as giving directions: "turn left, then right", those directions depend on where you start.

cd Documents           # Go into Documents from here
cd ../Desktop          # Go up one level, then into Desktop
cd src/components      # Go into src, then into components

Special path symbols

SymbolMeaningExample usage
.Current directory./script.sh (run script here)
..Parent directory (up one level)cd .. or ../config.json
~Home directory~/Documents or cd ~
-Previous directorycd - (go back)
05

A real-world navigation example

Imagine you are in your home folder and you want to get to /Users/you/Documents/Projects/my-app. You have several options:

# Step by step (good for learning, tedious daily)
cd Documents && cd Projects && cd my-app

# One relative path (fast from home)
cd Documents/Projects/my-app

# Absolute path (works from anywhere)
cd /Users/you/Documents/Projects/my-app

# Home shortcut (best of both worlds)
cd ~/Documents/Projects/my-app
06

Tab completion: your secret weapon

Never type full paths when you can press Tab. Start typing a path, then press Tab:

cd Doc<Tab>        # Completes to: cd Documents
cd Do<Tab><Tab>    # Shows: Documents/  Downloads/
cd /us<Tab>/bi<Tab>  # Expands to: cd /usr/bin

Tab completion works on directory names, file names, command names, Git branches, and basically everything in the terminalWhat is terminal?A text-based interface where you type commands to interact with your computer. Also called the command line or shell..

07

Quick reference

CommandWhat it doesExample
pwdShow current directorypwd
lsList files and foldersls or ls -la
cd folderEnter a directorycd Documents
cd ..Go up one levelcd ..
cd ~Go to home directorycd ~
cd -Go to previous directorycd -
cd /pathAbsolute navigationcd /var/log