Skip to main content
1 ● Beginner 10m

File System Navigation

Learn to navigate the Linux file system using essential command-line tools.

Learning Objectives

  • Use pwd to display the current working directory
  • Navigate directories with cd
  • List files and directories with ls
  • Understand absolute vs relative paths
  • Create directories with mkdir

Introduction

The Linux file system is organized as a hierarchical tree structure, starting from the root directory /. Understanding how to navigate this structure is fundamental to working with Linux.

Key Commands

pwd - Print Working Directory

Shows your current location in the file system:

$ pwd
/home/learner

ls - List Directory Contents

Lists files and directories:

$ ls           # Basic listing
$ ls -l        # Long format with details
$ ls -la       # Include hidden files (starting with .)
$ ls -lh       # Human-readable file sizes

cd - Change Directory

Navigate to different directories:

$ cd /var/log        # Absolute path (starts with /)
$ cd projects        # Relative path (from current directory)
$ cd ..              # Go up one level
$ cd ~               # Go to home directory
$ cd -               # Go to previous directory

mkdir - Make Directory

Create new directories:

$ mkdir myproject              # Create single directory
$ mkdir -p parent/child/grand  # Create nested directories

File System Structure

/                    # Root directory
β”œβ”€β”€ home/            # User home directories
β”‚   └── learner/     # Your home directory
β”œβ”€β”€ etc/             # System configuration files
β”œβ”€β”€ var/             # Variable data (logs, etc.)
β”œβ”€β”€ usr/             # User programs
└── tmp/             # Temporary files

Your Task

Create a project structure for a web application:

  1. Navigate to your home directory
  2. Create a projects directory
  3. Inside projects, create a webapp directory
  4. Create a README.md file inside webapp

Your final structure should look like:

/home/learner/
└── projects/
    └── webapp/
        └── README.md

Launch Your Sandbox

Copy the command below to start this exercise:

Launch Your Sandbox

Copy the command below to start this exercise in your terminal:

$infra-learn launch linux-01

Verification Criteria

The verification script will check the following when you run infra-learn verify:

  • 1 Created directory /home/learner/projects
  • 2 Created directory /home/learner/projects/webapp
  • 3 Created file /home/learner/projects/webapp/README.md
Need a hint? (3 available)
Hint 1

Use mkdir -p to create nested directories in one command

Hint 2

Use touch to create empty files

Hint 3

Remember: absolute paths start with /, relative paths don't