Lesson 3.2: Absolute and relative paths
Paths as addresses in the tree: absolute paths from /, relative paths from where you are, the shortcuts . .. ~ and -, and moving with pwd and cd.
15 min
You will learn to
- Tell absolute from relative paths
- Use . .. ~ and - correctly
- Move around with cd and check where you are with pwd
- Choose the shorter or safer path form for a task
Key terms
- Path
- The address of a file or directory: directory names separated by /, ending with the file's name.
- Absolute path
- A path that starts with /. It describes the way from the root and means the same thing wherever you are.
- Relative path
- A path that does not start with /. It starts from the current directory.
- Working directory
- The directory you are currently in; relative paths start from here. pwd prints it, cd changes it.
- Special names . .. ~ -
- . is the current directory, .. the one above it, ~ your home directory, and - (only with cd) the previous directory.
← The Linux filesystem hierarchy · All lessons · Working with files and directories →