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:
- Navigate to your home directory
- Create a
projectsdirectory - Inside
projects, create awebappdirectory - Create a
README.mdfile insidewebapp
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-01Verification 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