Relative and Absolute Paths

Learn about relative and absolute paths in a Linux environment for faster navigation.

We'll cover the following

Relatives paths

So far, we’ve been navigating using relative paths. That means we’ve been specifying the destination relative to our current working directory or our current location on the filesystem. When we’re at the filesystem’s root and type cd var, the var directory is something we can see with the ls command. We and the var directory are in the same location on the filesystem, and the command we specified said, “Switch to the var directory that’s in the same folder that I’m currently working in.”

Absolute paths

We can navigate the filesystem much more quickly by using the entire path to a directory from the filesystem’s root. Let’s navigate to the /usr/bin directory. We have to go to the /usr folder first and then open the bin directory in a GUI. But the cd command can take entire file paths so that we can jump to the /usr/bin directory in a single command.

$ cd /usr/bin

This command says:

  1. Go to the filesystem’s root.
  2. Go into the usr folder.
  3. Go into the bin folder.

Try moving around to a few locations this way. Navigate to the /usr/lib directory, and then navigate back to the /var directory:

$ cd /usr/lib
$ pwd

$ cd /var

$ pwd

Use the terminal below to try these commands.

Get hands-on with 1200+ tech skills courses.