Skip to main content

Command Palette

Search for a command to run...

Linux Filesystem Navigation: Understanding Paths and Directories

Updated
•3 min read•View as Markdown
M
Computer Engineering student sharing my journey through Linux, Networking, and Systems Administration.

Linux provides a simple but powerful way to navigate directories and work with files through the command line.

When learning Linux, understanding how to navigate the filesystem is one of the first essential skills to develop.

In this article, I'll cover some basic commands for navigating directories and explain the difference between absolute and relative paths.

  1. Understanding the Current Directory

When working in a Linux terminal, it's important to know which directory you're currently in.

The "pwd" command displays the full path of your current working directory.

pwd

For example, the output might be:

/home/user

This means the current working directory is "/home/user".

  1. Listing Files and Directories

The "ls" command displays the files and directories in the current directory.

ls

For example, the output might look like this:

Desktop Documents Downloads Pictures

The results depend on the contents of the directory you're viewing.

  1. Changing Directories

The "cd" command allows you to move from one directory to another.

For example:

cd Documents

This moves you into the "Documents" directory, assuming it exists inside your current directory.

You can then use "pwd" to check your current location:

pwd

To return to the parent directory, use:

cd ..

Understanding how to move between directories makes working in the Linux terminal much easier.

  1. Absolute Paths vs. Relative Paths

Linux supports two common ways to specify a directory's location.

Absolute Paths

An absolute path specifies a location starting from the root directory, represented by "/".

For example:

/home/user/Documents

This path identifies the "Documents" directory inside "/home/user", regardless of the current working directory.

Relative Paths

A relative path specifies a location in relation to the current working directory.

For example, if the current directory is "/home/user", you can enter:

cd Documents

Here, "Documents" is a relative path because it refers to a directory inside your current location.

The key difference is that an absolute path starts from the root directory, while a relative path depends on where you currently are.

  1. Putting It Together

Here is a simple example of navigating the filesystem:

pwd ls cd Documents pwd cd .. pwd

These commands let you check your current location, list directory contents, move into another directory, and return to the parent directory.

You can try these commands in your own Linux environment and observe how the current working directory changes.

Conclusion

Understanding filesystem navigation is a fundamental part of learning Linux.

Commands such as "pwd", "ls", and "cd" are simple, but they are used regularly when working with the command line.

As I continue learning Linux and Systems Administration, I'll keep documenting the commands, concepts, and practical lessons that help me build a stronger foundation.

This article is part of my ongoing Linux learning journey.