← WA Computer Science ATAR Unit 1

Folder hierarchy and file paths

The location of a file in the folder tree, written from the root (absolute, e.g. /home/sam/file.txt) or from the current folder (relative).

Understanding Folder hierarchy and file paths in WA Computer Science ATAR Unit 1

What it does: It has no leading / or drive letter, so it is read from the current folder and only works if you are in the right place. The double backslash starts a network path: \\server is the remote computer, shared is its shared folder, then the file. A relative path depends on where you are now. An absolute path is the one written from the root. Two dots mean the parent folder, which is one level up in the folder tree. The folder tree has one root (C:\ or /). Absolute paths always start there, whichever folder you are in. Linux separates folders with forward slashes (/). Windows uses backslashes (\).

Common mistakes: Linux paths use forward slashes. The absolute path to the folder is /home/sam, not \home\sam. ./ means the current folder (school), but file.txt is in /home/sam. The relative path must use ../ to go up one folder: cat ../file.txt.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 315–470) and word search (Modules 100–470).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which is an absolute path on a Windows computer?
Sam\file.txtC:\Users\Sam\file.txt
Matches
/home/sam/docs/../file.txt typed as the path to docs/file.txt
↓
The .. means go up one folder, so the path leads to /home/sam/file.txt, not into the docs folder.
Applying
Meanings
Term
file path
Meaning
The location of a file in the folder tree, written from the root (absolute, e.g. /home/sam/file.txt) or from the current folder (relative).
Practice
C:\Users\Sam\Documents\report.docx
Testing
Gaps
\Users\Sam\file.txt
Check Answer
Spots
1cd \home\sam
2ls

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Spider' badge — Web Weaver, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which is an absolute path on a Windows computer?
A. C:\Users\Sam\file.txt ✓
B. Sam\file.txt
An absolute path starts from the root of the drive (C:\) and gives the full location of the file. Sam\file.txt is relative to the current folder.
2. Which is an absolute path on a Linux computer?
A. /home/sam/file.txt ✓
B. sam/file.txt
On Linux, an absolute path begins with / (the root of the folder tree). sam/file.txt does not start at the root, so it is relative.
3. A relative path is written from...
A. The root of the drive
B. The current folder ✓
A relative path depends on where you are now. An absolute path is the one written from the root.
4. You are in /home/sam. Which relative path points to /home/sam/docs/file.txt?
A. docs/file.txt ✓
B. /docs/file.txt
docs/file.txt starts in the current folder. A leading / means the root, so /docs/file.txt would look for a docs folder directly under the root.
5. What does .. mean in a relative path such as ../file.txt?
A. Go down into a new subfolder
B. Go up one folder to the parent ✓
Two dots mean the parent folder, which is one level up in the folder tree.

Match the Pairs

C:\Users\Sam\file.txt → An absolute Windows path starting at the C: drive root and going down through the Users and Sam folders to file.txt
/home/sam/file.txt → An absolute Linux path starting at the root / and going through the home and sam folders to file.txt
A relative path locates a file starting from the current folder, not from the root → docs/report.txt
A network drive path locates a file on another computer using the server name and a shared folder → \\server\shared\file.txt
/home/sam/docs/../file.txt typed as the path to docs/file.txt → The .. means go up one folder, so the path leads to /home/sam/file.txt, not into the docs folder.
Using the relative path docs/report.txt from inside the docs folder → A relative path starts at the current folder, so from inside docs it looks for docs/docs/report.txt, which does not exist.

Key Term

file path
The location of a file in the folder tree, written from the root (absolute, e.g. /home/sam/file.txt) or from the current folder (relative).

Fill in the Blanks

1. C:\Users\Sam\file.txt
Hint: Type the drive letter and colon that mark the root of this Windows absolute path
2. /home/sam/file.txt
Hint: Type the single character that stands for the root folder in a Linux absolute path
3. ../notes/file.txt
Hint: Type the symbol that means go up to the parent folder in a relative path
4. \\server\share\file.txt
Hint: Type the two characters that start a network drive path
5. cd /home/sam cat ./file.txt
Hint: Type the symbol for the current folder, which a relative path starts from

Spot the Error

Question 1
A cd \home\sam
B ls
C cat file.txt
Line A — Linux paths use forward slashes. The absolute path to the folder is /home/sam, not \home\sam.
Question 2
A cd /home/sam
B mkdir school
C cd school
D cat ./file.txt
Line D — ./ means the current folder (school), but file.txt is in /home/sam. The relative path must use ../ to go up one folder: cat ../file.txt.
Question 3
A import os
B base = "/home/sam"
C path = base + "a.txt"
D print(path)
Line C — Without a / separator the result is /home/sama.txt. The folder and file name must be joined with a slash: base + "/a.txt".
Question 4
A cd C:\Users\Sam
B cd \Documents
C type file.txt
Line B — A leading backslash starts from the root of the drive, so this looks for C:\Documents. A relative path from C:\Users\Sam is just Documents.
Question 5
A net use Z: \fileserver\share
B cd Z:\reports
C type budget.txt
Line A — A Windows network drive path (UNC path) starts with two backslashes: \\fileserver\share. A single backslash is not a network location.

Student with a class code? Join your class →