Skip to content
DevOps devops linux 6 min read

Navigating the Filesystem

Before you can manage a server, install software, or read a log file, you need to move around the filesystem with confidence. The filesystem is just the tree of folders and files on your machine, and Linux gives you three small commands to explore it: pwd (where am I?), ls (what’s here?), and cd (take me somewhere). Master these and you’ll never feel lost in a terminal again. This page also explains paths, the most common source of “file not found” frustration for beginners.

The three commands you use constantly

Almost every terminal session starts with the same loop: find out where you are, look at what’s around you, then move. These commands map directly to those three questions.

CommandStands forWhat it does
pwdprint working directoryShows the full path of the folder you’re currently in
lslistLists the files and folders in a directory
cdchange directoryMoves you into a different folder

The working directory (also called the current directory) is simply the folder your terminal is “sitting in” right now. Commands you run usually act on this folder unless you tell them otherwise.

pwd — where am I?

Run pwd any time you’re unsure of your location. It prints one line: the absolute path to your current folder.

pwd

Output:

/home/ubuntu

That tells you that you’re in the home directory of a user named ubuntu, which is the default user on many Ubuntu cloud servers.

ls — what’s here?

ls lists the contents of a directory. On its own it shows the names in the current folder. Its real power comes from its options (the flags you add after it).

ls

Output:

Documents  Downloads  app.log  projects

By default ls hides anything that starts with a dot (.). These are hidden files (often config files like .bashrc). It also gives you almost no detail. Here are the flags you’ll use every day:

FlagMeaningWhy you want it
-llong formatShows permissions, owner, size, and modified date
-aallIncludes hidden dot-files
-hhuman-readableShows sizes as 4.0K, 2.3M instead of raw bytes

You can combine them. ls -la (or ls -lah) is the single most useful listing command:

ls -lah

Output:

total 28K
drwxr-xr-x 5 ubuntu ubuntu 4.0K Jun 15 09:12 .
drwxr-xr-x 3 root   root   4.0K Jun 10 18:40 ..
-rw-r--r-- 1 ubuntu ubuntu  220 Jun 10 18:40 .bashrc
-rw-r--r-- 1 ubuntu ubuntu 2.3K Jun 15 08:55 app.log
drwxr-xr-x 2 ubuntu ubuntu 4.0K Jun 14 21:30 projects

Reading that output left to right: the first column is permissions (a leading d means it’s a directory), then the owner and group, then the size, then the last-modified date, then the name. Notice the two entries . and .. at the top — they always appear with -a and we’ll explain them next.

Tip: On Ubuntu, ll is a built-in shortcut (an alias) for ls -alF. Type ll and you get the long listing for free. If it’s missing in a minimal install, it’s defined in ~/.bashrc.

The special path symbols: . .. ~ and /

Linux uses four shorthand symbols constantly. Learn them once and paths stop being confusing.

SymbolMeansExample
.the current directory./script.sh runs a script in this folder
..the parent directory (one level up)cd .. goes up one folder
~your home directorycd ~ or just cd returns you home (/home/ubuntu)
/the root directory (top of the whole tree)cd / goes to the very top

The root directory / is the single starting point of the entire Linux filesystem. Everything else lives somewhere underneath it, including system folders like /etc (config), /var/log (logs), and /home (user folders).

cd — moving around

cd takes one argument: where you want to go. Here are the moves you’ll make all day:

cd /var/log          # go to an exact location
cd projects          # go into a subfolder of where you are
cd ..                # go up one level
cd ../..             # go up two levels
cd ~                 # go home (cd with no argument does the same)
cd -                 # go back to the previous directory you were in

The cd - trick is a real time-saver: it bounces you between the last two directories, like the “back” button in a browser.

Absolute vs relative paths

This is the concept that trips up almost every beginner, so it’s worth slowing down. A path is just the address of a file or folder. There are two kinds.

An absolute path starts at the root / and spells out the full route. It always points to the same place no matter where you currently are.

cd /etc/nginx/sites-available
cat /var/log/nginx/access.log

A relative path starts from your current working directory. It does not begin with /. Where it lands depends entirely on where you are right now.

# If you are in /home/ubuntu:
cd projects/api        # goes to /home/ubuntu/projects/api
cat app.log            # reads /home/ubuntu/app.log
cd ../downloads        # goes up to /home/ubuntu, then into downloads

The same relative command behaves differently from a different starting point — that’s the whole point, and also the whole danger.

Path typeStarts withDepends on where you are?Best for
Absolute/No — always the same targetScripts, cron jobs, config files, anything that must be reliable
Relativea name, ., or ..YesQuick interactive navigation when you know where you are

When to use which

Use relative paths when you’re working interactively and moving short distances — they’re faster to type. Use absolute paths in anything automated: shell scripts, systemd service files, and cron jobs (scheduled tasks). A cron job runs from an unknown directory, so a relative path like app.log will silently look in the wrong place.

Gotcha: A leading / is the difference between two completely different files. cd etc tries to enter an etc folder inside your current directory, while cd /etc goes to the system-wide config directory. Forgetting the slash is the number-one cause of “No such file or directory” errors.

A quick worked example

Putting it all together, here’s a realistic exploration of a fresh Ubuntu server:

pwd                  # /home/ubuntu
ls -lah              # see what's in home, including hidden files
cd /etc/nginx        # jump to the nginx config (absolute path)
pwd                  # confirm: /etc/nginx
ls sites-available   # list configs without entering the folder
cd -                 # bounce straight back to /home/ubuntu

Best Practices

  • Run pwd whenever you’re unsure where you are before running a destructive command like rm.
  • Use ls -lah as your default listing — it shows hidden files, permissions, and readable sizes in one shot.
  • Use absolute paths in scripts, cron jobs, and systemd units; use relative paths only for quick interactive moves.
  • Remember the leading /: it switches a path from relative (in your folder) to absolute (from root).
  • Press Tab to auto-complete file and folder names — it prevents typos and shows you what’s available.
  • Use cd - to flip between two directories instead of retyping long paths.
Last updated June 15, 2026
Was this helpful?