Filesystem and configuration

The Linux filesystem tree

See one directory tree rooted at slash instead of separate drive letters and connect devices through mount points.

Linux has no drive letters. There is one directory tree, and every file on the machine lives somewhere inside it.

Every absolute path begins at /, the filesystem root. Read a path like /home/ada/notes.txt as a walk: start at the root, enter home, enter ada, arrive at notes.txt. User home folders normally live under /home.

List the top of the tree:

ls /
# bin  boot  dev  etc  home  lib  media  mnt  opt
# proc  root  run  sbin  srv  tmp  usr  var

Those first-level directories are the fixed landmarks of every Linux system. The next lesson covers what the important ones contain.

Where do other disks go?

On Windows, a second disk becomes D:. On Linux, a separate disk still appears somewhere inside this one tree after it is mounted. The mount point is an ordinary directory used as the entry to that filesystem.

You can ask which device backs any directory:

findmnt /
# TARGET SOURCE         FSTYPE OPTIONS
# /      /dev/vda1      ext4   rw,relatime

Here the root of the tree is served by the disk /dev/vda1. Mount a second disk at /mnt/data and everything under that path is stored on the second disk, while the rest of the tree stays on the first. Programs never notice — they just use paths.

The classic mount-point mistake

A directory used as a mount point is a normal directory, and that enables a confusing failure. If the disk is not mounted and you copy files into /mnt/data, those files land on the root disk. When the disk mounts there later, it covers them. The files look gone, and disk usage numbers stop adding up. Unmount, and they reappear.

So before writing into a mount point, check it with findmnt — if it prints nothing for that path, nothing is mounted there.

Complete the Shell Commands Course first if absolute paths, relative paths, and .. are new to you.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →