Skip to main content
Module 1 · Lesson 2 of 22/11 in the course~18 min
Module lessons (2/2)

Moving around the file system (cd)

In the terminal you don't navigate by double-clicking icons: you move the working directory cursor using cd (Change Directory). Understanding where a path is resolved from avoids the most common mistake made by beginners: No such file or directory.

Absolute vs Relative and shortcuts

Path shapeStarting pointExampleWhen it is best to use it
Absolute (/...)Always from the root /cd /home/user/documentsIn scripts or when you jump away from the current branch
Relative (dir/...)From current CWDcd documentsWhen you are already close to your destination and want speed
..Instant parent foldercd .. or cd ../logsTo go up one or more levels towards root
.Current folder itselfls .When a command requires a local explicit path
~Your home (/home/user)cd ~ (or just cd)To go home immediately from anywhere in the system

Progressive examples

1. Enter with a relative path and verify with pwd

Bash
pwd
# /home/user

cd documents
pwd
# /home/user/documents

2. Go up one level with .. and chain levels

Bash
pwd
# /home/user/documents

cd ..
pwd
# /home/user

Even outside the home page you can concatenate multiple .. with the slash: for example cd ../.. goes up two levels in a single command.

3. Use absolute paths from any location

Bash
cd /home/user/documents
pwd
# /home/user/documents

A route starting with / completely ignores where you are at that moment.

4. Return to home with ~ and recognize the incorrect paths

Bash
cd cartella_inesistente
# cd: cartella_inesistente: No such file or directory

cd ~
pwd
# /home/user

Practical exercises

Practice Stage

Step 1 — Relative movement

Exercise#linux.m1.l2.e1
Attempts: 0Loading…

Move inside the 'documents' folder using a relative path.

Loading editor…
Show hint

Use the cd command followed by a space and the name documents.

Solution available after 3 attempts

Practice Stage

Step 2 — Trace the parent

Exercise#linux.m1.l2.e2
Attempts: 0Loading…

Go back to the parent (parent) folder of your current location.

Loading editor…
Show hint

Use a colon (..) instead of a single period to indicate the parent directory.

Solution available after 3 attempts

Practice Stage

Step 3 — Return to the home page and back

Exercise#linux.m1.l2.e3
Attempts: 0Loading…

Move inside the 'documents' folder and immediately return to your home directory using the special shortcut ~.

Loading editor…
Show hint

Add the cd ~ command to the second line to return to /home/user.

Solution available after 3 attempts


Quick check

Linux Quiz#linux.m1.l2.e4
Ready

Your current pwd is /home/user. Which command tries to enter the wrong location and generates No such file or directory?

Answer options
Linux Quiz#linux.m1.l2.e5
Ready

You are at /home/user/documents and execute cd .. followed by pwd. What does the shell print?

Answer options