Absolute and Relative Paths
Two ways to say where.
There are two ways to describe where a file is. Think of giving someone directions. You could give the full address, or you could say, from here, turn left. Paths work the same way.

- Two ways to say where
- A full address
- Or directions from here
Two kinds of path
An absolute path starts with a slash. It begins at the root, so it works from anywhere, like a full address. A relative path doesn't start with a slash. It starts from the folder you're in right now, like directions from here.
Absolute path
- Starts with /
- Begins at the root
- Works from anywhere
Relative path
- No / at the start
- Begins where you are
- Shorter to type
Both reach the same file
Here we read the CV file twice, with cat, which prints a file. First with the absolute path, slash home slash sam slash Documents slash CV dot TXT. Then with the relative path, Documents slash CV dot TXT. From the home folder, both lead to exactly the same file.
cat /home/sam/Documents/cv.txt Sam Lee Junior developer Skills: Linux, Python, Git cat Documents/cv.txt Sam Lee Junior developer Skills: Linux, Python, Git
Relative paths depend on where you are
But relative paths change meaning when you move. After CD Music, the same relative path, Documents slash CV, fails, because there's no Documents folder inside Music. The absolute path would still work. That's the trade off.
cd Music cat Documents/cv.txt cat: Documents/cv.txt: No such file or directory
Summary
Absolute paths start with a slash, and work from anywhere. Relative paths start from where you are. Next, a few special shortcuts in paths.
Key takeaways- Absolute: starts with /
- Relative: from here
- Relative depends on where you are