Paths in Linux: absolute and relative
Updated November 1, 2026
An absolute path is a path from the root /, while a relative path is read from the current directory.
Common cases
/home/student/file # absolute: from the root, always the same
docs/file # relative: from the current directory
.. # the directory one level up
cd ~/project && cat ../notes.txt # .. goes up one levelSample output
$ pwd
/home/student/project
$ ls
src
$ cat ../notes.txt
buy milk
$ cd /etc
$ pwd
/etc
$ cat ../notes.txt
cat: ../notes.txt: No such file or directoryHow it works: . and .. and the tilde
Every directory has two special entries:
.is the directory itself and..is its parent. So./scriptruns a file from the current directory, andcd ..moves one level up.~is shorthand for your home directory, which the shell expands to/home/student. An absolute path does not depend on where you stand; a relative path is shorter but changes meaning when you change directory.
Common mistakes
The tilde expands only when it is unquoted. ls "~/notes.txt" prints ls: cannot access '~/notes.txt': No such file or directory even though the file is there. Inside quotes ~ stays an ordinary character of the name, so ls looks under the current directory for a file with that exact name. Drop the quotes and the same command finds /home/student/notes.txt.
cd .. from a directory you entered through a symbolic link does not land where the files physically live. Say s/link points at s/real/deep. After cd s/link, pwd prints /home/student/s/link while pwd -P prints /home/student/s/real/deep. cd .. from there leaves you in /home/student/s, not in /home/student/s/real: the shell counts .. along the path you walked.
A relative path inside a script is read from the directory you started the script in, not from the directory the script sits in. The script app/run.sh with the line cat config.yml works while you stand in app. Run it as ./app/run.sh one level up and you get cat: config.yml: No such file or directory. The file did not move. The lookup happened somewhere else.
Used in
You need this in the lesson The filesystem and navigation. The theory is the chapter The filesystem and moving around.
See also
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.