Script Valley
Linux Basics Complete Course: From Beginner to System Administrator
Module 2: Linux File System and NavigationLesson 2.2

Navigating the Linux File System | cd ls pwd Commands

cd command, ls command, pwd command, absolute path, relative path, Linux navigation

Navigating the Linux File System

Navigation is one of the most fundamental Linux terminal skills. Three commands — pwd, ls, and cd — are used constantly throughout every Linux session. Mastering them is the first step to becoming fluent with Linux commands.

The ls Command

The ls command lists the contents of a directory. By default it shows files and subdirectories in the current directory. With the -l flag it displays a detailed long listing including permissions, owner, size, and modification date. The -a flag shows hidden files, which begin with a dot.

ls
ls -l
ls -la
ls -lh /var/log

The -h flag makes file sizes human-readable, showing KB, MB, or GB instead of raw byte counts. You can combine flags: ls -lah gives a long listing with hidden files and human-readable sizes.

The cd Command

The cd command changes your current directory. Without arguments, it takes you to your home directory. You can supply an absolute path (starting from /) or a relative path (relative to your current location).

cd /etc
cd ~
cd ..
cd /home/alice/Documents
cd -

The double dot (..) always refers to the parent directory. A single dot (.) refers to the current directory. The hyphen (-) in cd takes you back to the previous directory you were in, which is very useful when switching between two locations.

Absolute vs Relative Paths

An absolute path always starts with a forward slash and describes the full location from the root: /home/alice/projects/app.py. A relative path describes a location relative to where you currently are. If you are in /home/alice, the relative path to that same file is projects/app.py or ./projects/app.py.

Useful Navigation Shortcuts

The Tab key auto-completes file and directory names, saving typing and avoiding typos. Pressing Tab twice shows all possible completions when there are multiple matches. The up and down arrow keys cycle through command history, letting you quickly re-run previous commands.

cd /var/log
pwd
ls -lh
cd ../../etc
pwd

Practice switching between directories using both absolute and relative paths. The more you use the terminal for navigation, the faster and more intuitive it becomes. This is the core of everyday Linux command usage.

Up next

Finding Files in Linux | find, locate, which Commands

Sign in to track progress