File Paths
A path tells a tool where to look; a relative path needs a starting location.
Understand the idea
A file path describes a route to a file or folder. An absolute path starts from a filesystem root; a relative path starts from a location supplied by the context. The example uses POSIX-style paths, as in many macOS and Linux shells. Windows paths may use a drive and different separators, so do not assume the exact spelling is portable.
In a terminal, a relative path commonly starts from the shell’s current working directory. In other contexts the base can be different: for example, a relative image path in a web page is interpreted relative to that page’s location. Ask “relative to what?” before treating two identical-looking paths as the same location.
If the base is /home/learner/human-lab, the path notes/plan.txt points into its notes folder. Moving to a different base changes what that relative path identifies. Keep spelling and capitalization consistent; some filesystems distinguish Plan.txt from plan.txt.
Key points
- 01 An absolute path identifies a location starting from a filesystem root.
- 02 A relative path needs a base location to have a specific meaning.
- 03 Folder names form successive steps toward the target file.
- 04 The correct base depends on the tool or document interpreting the path.
- 05 Capitalization and separators can matter across operating systems.
Worked example
Resolve a relative path
A worked example using sample data. Nothing here runs on your computer.
Base folder: /home/learner/human-lab
Relative path: notes/plan.txt/home/learner/human-lab/notes/plan.txtThis is a simple illustrative POSIX path with no symbolic links or special components. It is not a command to paste or a claim about your username or folders.
Visual
flowchart LR B["Base: human-lab"] --> N["notes"] N --> P["plan.txt"]
Follow the primary sources
An original HWTL explanation, prepared and independently checked with AI against the sources below. This lesson has not yet been tested with human learners.
Source review completed 2026-10-07.
- MDN: Dealing with files
Relative file references depend on the invoking file’s location; subfolders, parent folders, and filename capitalization matter.
- MDN: Command line crash course
The terminal examples distinguish absolute paths beginning with a root slash from paths relative to the present working directory.
Practice · predict the result
Resolve the path from the given base
A small test from your robot instructors. Hints are welcome.
What you will practice: Resolve a simple relative path from an explicitly stated base folder.
Sample scenario. Synthetic POSIX-style paths. There are no symbolic links, parent-directory components, expansion, or hidden base changes. This computes a path, not proof a file exists.
- Base folder
/home/learner/human-lab- Relative path
notes/plan.txt
The base folder is /home/learner/human-lab. Which absolute path does notes/plan.txt identify from that base?
Attempts stay on this browser and are kept separate from lesson views and your self-reported knowledge.
Sources and exercise scope
- MDN: Dealing with files
Nested project folders, file names and extensions, and relative file references.
- POSIX.1-2024: pwd
Plain pwd reports the current working directory as an absolute path, followed by a newline.
- MDN: Command line crash course
Terminal, shell, and command-line distinctions; an absolute path starts at a root while a relative path depends on the working directory.
Original synthetic exercise, checked with AI against primary documentation on 2026-10-08. Human learner validation is pending. A result here records this attempt; it does not establish mastery.
Make this lesson yours
Save it for later, or tell your robot what would help.
This correction stays on this browser. Browse all concepts if the topic is missing.
Familiarity is your own assessment. To use it in your coding tool, download your updated learning profile.
Choices are saved on this browser. They do not sync to your account or coding tool.
Lesson diagnostics
Download the public lesson material, resource choices, and robot text selected for this page. The file does not include your chat, code, or saved profile. Nothing from the trace is uploaded.
It records the page’s selections, not video playback or proof of learning. A link from your coding tool does not supply its original recommendation trace.
Enable JavaScript to create a trace on this device.