Skip to content

Navigating the Filesystem

One of the first skills every Linux user must master is navigating the filesystem. Whether you're troubleshooting a production server, deploying applications, or managing cloud infrastructure, understanding how to move around the Linux filesystem efficiently is essential.


Learning Path

Linux Mastery → Module 2: Linux Command Line Essentials → Lesson 3

Difficulty: Beginner

Reading Time: 20 Minutes

Course Progress

Course: Linux Mastery

Module: Linux Command Line Essentials

Lesson: 3 of 10


What You'll Learn

After completing this lesson, you'll be able to:

  • Navigate directories confidently
  • Understand absolute and relative paths
  • Use navigation commands efficiently
  • Move between directories quickly
  • Access hidden files
  • Use tab completion for productivity
  • Navigate Linux like a professional

Prerequisites

Before starting this lesson, complete:

  • Module 1 – Linux Fundamentals
  • Understanding the Shell
  • Bash Basics

Why Learn Filesystem Navigation?

Every Linux task begins with navigation.

Whether you're:

  • Editing configuration files
  • Viewing logs
  • Deploying applications
  • Running scripts
  • Managing Docker
  • Configuring Kubernetes

you'll constantly move between directories.

Professional Linux administrators spend hundreds of times each day navigating the filesystem.


Understanding the Linux Filesystem

Unlike Windows:

C:\Users\John

Linux has only one filesystem.

Everything begins from:

/

Example:

/

├── home
│   └── basha
│       └── projects
├── etc
├── var
├── usr
└── tmp

Current Working Directory

Every terminal session has a Current Working Directory (CWD).

Display it:

pwd

Example:

/home/basha

Whenever you execute a command, Linux assumes you're referring to the current directory unless you specify another location.


Listing Files

Display files:

ls

Example:

Documents
Downloads
Pictures
projects

Detailed Listing

ls -l

Displays:

  • Permissions
  • Owner
  • Group
  • Size
  • Date
  • File Name

Display Hidden Files

ls -a

Example:

.bashrc

.profile

.gitconfig

Hidden files begin with a dot (.).


Most Common Option

ls -la

Displays:

  • Hidden files
  • Detailed information

This is the most commonly used ls command.


Changing Directories

Move into a directory:

cd Documents

Display location:

pwd

Output:

/home/basha/Documents

Return to Home Directory

Simply type:

cd

or

cd ~

Both commands take you to your home directory.


Move to Parent Directory

cd ..

Example:

/home/basha/projects


cd ..


/home/basha

Move Up Multiple Levels

cd ../..

Example:

/home/basha/projects/demo


cd ../..


/home

Previous Directory

Switch back to the previous directory:

cd -

Example:

/home/basha


cd /etc


cd -


/home/basha

Very useful during troubleshooting.


Root Directory

Navigate directly to the root:

cd /

Display location:

pwd

Output:

/

Absolute Paths

Absolute paths begin from the root directory.

Example:

cd /home/basha/projects

No matter where you currently are, Linux navigates to the exact location.


Relative Paths

Relative paths begin from the current directory.

Example:

Current:

/home/basha

Navigate:

cd Documents

Linux interprets:

/home/basha/Documents

Absolute vs Relative Paths

Absolute Path Relative Path
Starts with / Starts from current directory
Independent of location Depends on current directory
Always reaches the same location Changes based on where you are

Special Directory Symbols

Symbol Meaning
. Current Directory
.. Parent Directory
~ Home Directory
/ Root Directory

Examples:

Current directory:

cd .

Parent:

cd ..

Home:

cd ~

Root:

cd /

Tab Completion

Instead of typing:

cd Documen

Press:

Tab

Linux automatically completes:

cd Documents

Benefits:

  • Faster
  • Fewer typing mistakes
  • Increased productivity

Professional Linux administrators use Tab completion constantly.


Viewing Directory Contents

Display files:

ls

Display hidden files:

ls -a

Display detailed information:

ls -l

Human-readable sizes:

ls -lh

Most common combination:

ls -lah

Tree View

Some Linux systems include:

tree

Example:

projects

├── app.py

├── Dockerfile

├── README.md

└── src

If not installed:

Ubuntu:

sudo apt install tree

Real Production Example

Suppose you're troubleshooting NGINX.

Navigate:

cd /etc/nginx

View files:

ls -la

Open configuration:

cat nginx.conf

Move to logs:

cd /var/log/nginx

View log files:

ls

Every production troubleshooting session involves filesystem navigation.


Production Perspective

Cloud Engineers frequently navigate directories such as:

/etc

Configuration
/var/log

Logs
/home

Scripts
/opt

Applications
/usr/local/bin

Custom Commands

Efficient navigation saves valuable time during incidents.


Hands-on Lab

Task 1

Display current directory.

pwd

Task 2

List files.

ls

Task 3

Display hidden files.

ls -la

Task 4

Navigate to:

cd /etc

Display current location.

pwd

Task 5

Move to home.

cd ~

Task 6

Move to previous directory.

cd -

Task 7

Navigate to root.

cd /

Task 8

Explore:

cd /var/log

ls

Command Deep Dive

Command Purpose Example
pwd Print current directory pwd
ls List files ls -la
cd Change directory cd /etc
tree Directory tree tree

Mini Challenge

Without referring to this lesson:

  1. Go to your home directory.
  2. Navigate to /etc.
  3. Return to your previous directory.
  4. Navigate to /var/log.
  5. Display hidden files.
  6. Return to your home directory.
  7. Display your current directory.

Best Practices

  • Use absolute paths in automation scripts.
  • Use relative paths when working interactively.
  • Always verify your location using pwd.
  • Use Tab completion instead of typing full names.
  • Use cd - to quickly switch between directories.

Common Mistakes

❌ Confusing / and ~.

/ is the root directory.
~ is your home directory.


❌ Forgetting your current location.

✅ Use:

pwd

before executing important commands.


❌ Typing long paths manually.

✅ Use Tab completion.


Interview Questions

Beginner

  1. What does pwd do?
  2. What is the purpose of cd?
  3. What is the difference between ls and ls -la?
  4. What does ~ represent?

Intermediate

  1. Explain absolute and relative paths.
  2. What does cd - do?
  3. What are hidden files?
  4. Why is Tab completion useful?

Architect Level

  1. Why should automation scripts use absolute paths?
  2. How can efficient filesystem navigation reduce incident response time?
  3. Which directories do you commonly visit during production troubleshooting?

Summary

In this lesson, you learned:

  • Filesystem navigation
  • pwd
  • ls
  • cd
  • Absolute and relative paths
  • Hidden files
  • Tab completion
  • Navigation best practices

Efficient navigation is a fundamental Linux skill. As your systems become larger and more complex, the ability to move quickly through the filesystem will significantly improve your productivity.


Key Takeaways

  • pwd shows your current location.
  • ls lists directory contents.
  • cd changes directories.
  • / is the root directory.
  • ~ is your home directory.
  • Use absolute paths for scripts and automation.
  • Use Tab completion to work faster.

What's Next?

File and Directory Commands

In the next lesson, you'll learn:

  • Creating files
  • Creating directories
  • Copying files
  • Moving files
  • Renaming files
  • Deleting files safely
  • File permissions during file operations
  • Real-world administration examples