/ linux / fs

Understanding the Linux filesystem hierarchy is essential for navigating and managing any Linux system. Everything in Linux is a file — from text documents to hardware devices — and they are all organised under a single tree starting at the root (/).

the filesystem hierarchy standard (FHS)

Most Linux distributions follow the Filesystem Hierarchy Standard, which defines the purpose of each top‑level directory. This consistency makes it easier to find files and develop software that works across different distros.

Below is a breakdown of the most important directories you'll encounter.

key directories

/

The root directory. Every file and directory starts here.

/bin

Essential command binaries (e.g., ls, cp, mv) needed for system boot and repair.

/boot

Static bootloader files, kernel images, and initramfs.

/dev

Device files representing hardware components (e.g., /dev/sda for hard disk).

/etc

Host‑specific system configuration files. Often called 'the everything to configure' directory.

/home

Personal directories for regular users. Each user gets a subfolder (e.g., /home/alice).

/lib

Essential shared libraries and kernel modules needed by binaries in /bin and /sbin.

/media

Mount point for removable media like USB drives or CDs (automatically mounted).

/mnt

Temporary mount point for manually mounting filesystems.

/opt

Optional application software packages. Often used by third‑party tools.

/proc

Virtual filesystem providing process and kernel information as files.

/root

Home directory for the root (superuser) account.

/sbin

Essential system binaries (e.g., fdisk, ifconfig) primarily for system administration.

/srv

Data for services provided by the system (e.g., web server files).

/sys

Virtual filesystem that exposes kernel objects (devices, drivers, etc.).

/tmp

Temporary files. Often cleared on reboot.

/usr

Secondary hierarchy for user programs and data. Contains /usr/bin, /usr/lib, /usr/share, etc.

/var

Variable files — logs, spool files, caches, and other data that changes frequently.

mounting and devices

In Linux, storage devices (like hard drives, USBs, or CD‑ROMs) are not accessed directly by drive letters. Instead, they are mounted to a directory, making their contents available under that path. For example, a USB stick might appear as /media/usb.

The /dev directory contains special device files that represent hardware (like /dev/sda for a SATA drive). The mount command attaches a device to a directory, and umount detaches it.

exploring the filesystem

  • pwd — print current working directory
  • ls — list directory contents
  • cd — change directory
  • tree — display directory structure as a tree (often needs installation)
  • df -h — show disk usage of mounted filesystems
  • du -sh — estimate file/folder size
  • mount — list mounted filesystems or mount a device