A. Melih Yılmaz

Understanding file paths in Linux

Distinguishing absolute and relative paths through a small terminal exercise.

Screenshot of a sample terminal session prepared for this article.
Screenshot of a sample terminal session prepared for this article.

When working in a terminal, we first need to know our current directory. The pwd command shows it. The ls command lists directory contents, while cd changes the working directory.

An absolute path starts at the root directory. /home/melih/projects describes a complete location. A relative path depends on the current directory. cd .. moves up one level. This example only navigates directories and does not delete files.

$ pwd
/home/melih
$ mkdir -p projects/demo
$ cd projects/demo
$ pwd
/home/melih/projects/demo
$ cd ..
All articles