0
0
Linux CLIscripting~15 mins

Absolute vs relative paths in Linux CLI - Hands-On Comparison

Choose your learning style9 modes available
Understanding Absolute vs Relative Paths in Linux CLI
📖 Scenario: You are organizing files in your home directory on a Linux system. You want to practice using absolute and relative paths to navigate and list files.
🎯 Goal: Learn how to use absolute and relative paths to list files in different directories using the ls command.
📋 What You'll Learn
Use absolute paths starting from root /
Use relative paths starting from current directory .
Understand difference between absolute and relative paths
💡 Why This Matters
🌍 Real World
Knowing absolute and relative paths helps you manage files and folders efficiently on any Linux system.
💼 Career
System administrators, developers, and anyone working with servers or command line need to understand paths to navigate and automate tasks.
Progress0 / 4 steps
1
Create a directory structure
Create a directory called project inside your home directory /home/user and inside project create a directory called docs. Use the mkdir -p /home/user/project/docs command.
Linux CLI
Need a hint?

Use mkdir -p to create nested directories in one command.

2
Create a config file
Create an empty file called config.txt inside the docs directory using the absolute path /home/user/project/docs/config.txt. Use the touch command.
Linux CLI
Need a hint?

Use touch with the full absolute path to create the file.

3
List files using relative path
Change directory to /home/user/project using cd. Then list the files inside the docs directory using a relative path with ls docs.
Linux CLI
Need a hint?

Use cd /home/user/project to move to the project directory, then ls docs to list files inside docs using relative path.

4
List files using absolute path
From any directory, list the files inside /home/user/project/docs using the absolute path with ls /home/user/project/docs.
Linux CLI
Need a hint?

Use ls /home/user/project/docs to list files with absolute path. The output should show config.txt twice from both ls docs and ls /home/user/project/docs.