Unit 1 · What is Linux? · Lesson 5 of 34
Path Pandemonium
Understanding File Paths in Linux
When interacting with the file system, you will most definitely need to understand how paths work. Every file and directory within the file system has its own unique path, which is an address within the file system hierarchy.
The path can be constructed in two ways: relative to the address you are currently at, or relative to the root. These are known as the Relative Path and Absolute Path, respectively.
Example
For example, a text file called flag.txt located in your documents dir within your home directory (/home, where all user directories are stored, including yours) can be accessed in two ways, assuming your current path is set to your home directory.
- Relative Path:
documents/flag.txt - Absolute Path:
/home/user/documents/flag.txt
You will often use both of these pathing standards while using Linux, so get used to using both.
Path Shortcuts
There are also a few shortcuts you'll see in paths all the time:
So if you're in /home/user/documents, then .. is /home/user, and ../.. is /home. You'll be using these a LOT once you start moving around in the next unit.
Do this lesson for real
With a free account you get the terminal, the challenges and the checks that go with every lesson in Intro to Linux, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.