In Linux, every file and directory has a location. To tell a command which item to work with, you use a path. Paths mainly come in two forms: absolute and relative.
Absolute paths
An absolute path begins at the root directory / and gives a complete location, such as /home/alice/Documents/report.txt. Because the location is complete, cd /var/log targets the same /var/log whether you start in /tmp or /home/alice.
/homealiceDocumentsreport.txt
Read left to right: root → home → Alice's home → Documents → the final file.
Relative paths
A relative path does not begin with /. It starts at the current working directory. From /home/alice, cd Documents targets /home/alice/Documents; from /home/bob, the same path targets /home/bob/Documents.
Three useful symbols
. · current directory ls . lists this directory; ./setup.sh explicitly runs a script from here.
.. · parent directory From /home/alice/Documents, cd ../.. moves up two levels to /home.
~ · home shortcut For Alice, ~ normally expands to /home/alice, so cd ~/Documents works.
Multiple components Components are separated by /, as in Documents/project or ../bob.
When should you use each form?
Absolute paths suit fixed locations, system directories, and scripts or configuration that should not depend on the current directory. Relative paths are convenient when the target is nearby, especially inside a project. From /home/alice/projects/myapp, cd src is usually clearer than repeating the full path.
Quick test: a path beginning with / is absolute. Documents/report.txt, ../Downloads, and ./script.sh are relative. ~ is a shell shortcut expanded before the command runs.
Path Resolver
Simulated terminal ready. Run commands and watch the filesystem on the right.
/homealicearchivebackupcachedataindex.bin
DocumentsDownloadsemptyPicturesprojectsrcREADME.md
.bashrc.profileaccess.logapp.logdraft.txterror.lognotes.txt
varlogsyslog
Quick buttons fill the prompt; run the command or press Enter to change terminal and filesystem state.KNOWLEDGE QUIZ
KNOWLEDGE QUIZ
Write Paths for a Backup Task
You are in /home/alice/projects/site. Write one command per task using the requested path form.
- List the project's assets directory with a relative path.
- Enter sibling project /home/alice/projects/api with a relative path.
- List /var/log with an absolute path.
- Use ~ to enter Alice's Documents.