Script Valley
Developer Environment Setup (WSL, Terminal, VS Code)
Linux Terminal FundamentalsLesson 2.1

How to navigate the Linux filesystem with cd, ls, and pwd

pwd command, cd absolute vs relative paths, ls flags, home directory tilde shortcut, hidden files, filesystem hierarchy

Navigating the Linux Filesystem

Linux filesystem navigation diagram

Every command you run in the terminal happens inside a directory. These three commands tell you where you are and let you move around.

pwd โ€” print working directory

pwd
# /home/yourname

pwd prints your current location. Run it whenever you feel lost.

ls โ€” list directory contents

ls            # basic list
ls -l         # long format: permissions, size, date
ls -la        # includes hidden files (names starting with .)
ls -lh        # human-readable sizes (KB, MB)

Files beginning with . are hidden by default. Your shell config (.bashrc, .zshrc) and SSH keys (.ssh/) live here.

cd โ€” change directory

cd /etc               # absolute path
cd Documents          # relative path
cd ..                 # go up one level
cd ~                  # go to home directory
cd -                  # go back to previous directory

Absolute paths start with /. Relative paths do not. ~ always expands to your home directory.

Practical flow

pwd
ls -la
cd ~/projects
ls

Tab completion works in every directory: type the first few letters of a name and press Tab. Double-Tab lists all matches.

Up next

How to create, copy, move, and delete files in the Linux terminal

Sign in to track progress

How to navigate the Linux filesystem with cd, ls, and pwd โ€” Linux Terminal Fundamentals โ€” Developer Environment Setup (WSL, Terminal, VS Code) โ€” Script Valley โ€” Script Valley