A configuration file vanished after an update, a service writes its logs somewhere unexpected, a /var disk is full for no obvious reason: these situations come up often in Linux administration. The answer is almost always the same: know where Linux keeps each type of file.
The Filesystem Hierarchy Standard (FHS) is the convention that defines what each main directory is for: configuration, logs, programs, user data. When you know these directories, you know where to look for a file.
What you will learn
- Identify the role of each functional area of the tree (
/etc/,/var/,/usr/,/run/…) - Know where to look for configuration, logs, binaries and runtime data
- Tell apart the differences between distributions (Debian/Ubuntu, RHEL/Rocky, Alpine)
- Diagnose a problem by targeting the right directory
- Avoid the usual file placement mistakes
Two pages cover the FHS, and they do not do the same thing. The Linux fundamentals guide gives the overview: the annotated tree, three administration reflexes, a short lab. This one goes into the detail of each area, with the commands to check it and the administration cases attached to it.
Where should you look? The admin reflex
Before going into detail, here is a table that tells you where to look. Read it from left to right: what you are looking for, the directory that holds it, and the quick command that confirms it.
| You are looking for… | Look in… | Quick command |
|---|---|---|
| The configuration of a service | /etc/ | ls /etc/<service>/ |
| The logs of a service | /var/log/ or journalctl | journalctl -xeu <service> |
| A binary or a command | /usr/bin/, /usr/sbin/ | which <command> |
| The runtime state (PID, socket) | /run/ | ls /run/<service>/ |
| The persistent data of a service | /var/lib/ | ls /var/lib/<service>/ |
| A temporary file | /tmp/ or /var/tmp/ | ls /tmp/ |
| A user's files | /home/<user>/ | ls -la /home/<user>/ |
| The boot files | /boot/ | ls /boot/ |
| A device (disk, partition) | /dev/ | lsblk |
What does each area of the FHS contain?
The FHS sorts files by two criteria: can they be shared between machines, and can they change while the system runs. That classification explains why some directories look redundant at first sight.
/etc/: the system configuration
You will come back to this directory often. Every installed service drops its configuration there, as text files you can edit.
Common subdirectories:
| Path | Contents |
|---|---|
/etc/ssh/ | SSH server and client configuration (sshd_config, host keys) |
/etc/systemd/ | Local overrides of systemd units |
/etc/apt/ or /etc/yum.repos.d/ | Package sources (Debian/Ubuntu or RHEL/Rocky) |
/etc/netplan/ or /etc/NetworkManager/ | Persistent network configuration |
/etc/fstab | Table of persistent mounts |
/etc/passwd, /etc/shadow, /etc/group | User accounts and groups |
/etc/sudoers, /etc/sudoers.d/ | Privilege delegation rules |
/etc/logrotate.d/ | Log rotation rules |
/etc/crontab, /etc/cron.d/ | System scheduled tasks |
# List the subdirectories of /etc to see which services are configuredls -d /etc/*/For systemd units, one rule applies: never edit a file in
/usr/lib/systemd/. That path belongs to the package manager, which
rewrites its contents on the next update and wipes your changes without
warning. Copy the file into /etc/systemd/system/ to create a local
override: it takes precedence over the package file and survives updates.
Related guides: Users and groups, sudo, Persistent mounts, systemd.
/var/: variable data
/var/ stores everything that changes over time: logs, caches, queues, and the databases of services. Each subdirectory has its own rule about what you may clean.
| Path | Contents | Why it matters |
|---|---|---|
/var/log/ | System and application logs | First place to check during an incident |
/var/lib/ | Persistent state of services (databases, packages) | Do not delete without understanding |
/var/cache/ | Package manager caches | Can be cleaned to recover space |
/var/spool/ | Queues (printing, mail, cron) | Rarely edited by hand |
/var/tmp/ | Temporary files kept across reboots | More durable than /tmp/ |
Focus: /var/log/, the logs
Logs help you diagnose an incident. It is the file names that vary with the distribution: the same information lives in different files on Debian and on RHEL. On Debian, rsyslog has no longer been installed by default since Debian 12 (Debian 12 release notes): system messages are therefore read with journalctl.
Without the rsyslog package, the files /var/log/syslog,
/var/log/auth.log and /var/log/kern.log do not appear, and system messages
are read with journalctl. If you install rsyslog, these three files are
created.
| File | Contents |
|---|---|
/var/log/journal/ | systemd binary journal, read with journalctl |
/var/log/dpkg.log | APT installs and updates |
/var/log/apt/ | History and output of APT commands |
/var/log/syslog | General system messages (with rsyslog only) |
/var/log/auth.log | Logins, authentication, sudo (with rsyslog only) |
/var/log/kern.log | Kernel messages (with rsyslog only) |
/var/log/apache2/ | Apache logs (if installed) |
On RHEL and AlmaLinux, it is rsyslog that writes /var/log/messages and
/var/log/secure; journalctl remains available to read the systemd journal.
| File | Contents |
|---|---|
/var/log/messages | General system messages |
/var/log/secure | Logins, authentication, sudo |
/var/log/dnf.log | DNF installs and updates |
/var/log/boot.log | Boot messages |
/var/log/httpd/ | Apache logs (if installed) |
Logs keep growing, and that has a consequence worth anticipating: on a
production server, if /var/ shares the partition (a portion of the disk) of /, a full disk blocks
the whole system, not only logging. Hence the common practice of putting
/var/ on a separate partition, and the monitoring reflex that goes with
it, df -h /var.
# See how much space the logs takedu -sh /var/log/
# Check the space left on the partitiondf -h /var
# Read the latest system journal entriesjournalctl -n 50 --no-pagerRelated guides: Logs with journalctl, Rotation with logrotate and Monitor disk space.
/usr/: binaries, libraries and documentation
/usr/ holds most of the programs and libraries installed by the package manager. Its contents only change when you install or update packages.
| Path | Contents |
|---|---|
/usr/bin/ | User commands (ls, grep, systemctl, vim…) |
/usr/sbin/ | Administration commands (fdisk, useradd, iptables…) |
/usr/lib/ | Shared libraries (.so) and support files |
/usr/lib/systemd/ | systemd units shipped by packages (do not edit here) |
/usr/share/ | Documentation, architecture-independent files |
/usr/local/ | Software installed by hand (outside the package manager) |
A bit of history explains what you will see on a recent machine.
/bin/ and /sbin/ used to be separate directories, reserved for the
binaries needed to boot. On Debian 12+, Ubuntu 22.04+,
RHEL 9+, Fedora and Arch, they are now symbolic links to
/usr/bin/ and /usr/sbin/, that is, shortcuts that point to another
location (the guide
Hard and symbolic links
covers them in detail). This is the merge known as usr-merge. In practice,
ls /bin and ls /usr/bin show the same contents.
The merge actually covers 4 directories, not two: /lib/ and
/lib64/ are also links to usr/lib/ and usr/lib64/. A second, more
discreet wave targeted /var: /var/run and /var/lock now point to
/run and /run/lock. Knowing this avoids a common confusion, because you
still come across /var/run/something.pid in plenty of scripts and
documentation: those paths still work, but no longer designate the place you
think.
The loop below establishes the real state of your machine in one go:
for d in /bin /sbin /lib /lib64 /var/run /var/lock; do printf '%-11s -> %s\n' "$d" "$(readlink "$d" || echo '(not a link)')"doneOn an Ubuntu 24.04 machine, all six entries are links:
/bin -> usr/bin/sbin -> usr/sbin/lib -> usr/lib/lib64 -> usr/lib64/var/run -> /run/var/lock -> /run/lockA few more commands locate a program and what it depends on:
# Check that /bin really is a link to /usr/binls -ld /bin /sbin
# Find where a command liveswhich systemctltype -a ls
# See the libraries a program usesldd /usr/bin/ls/opt/ and /usr/local/: software outside packages
These two directories hold software installed outside the package manager, but with different conventions: /opt/ receives a complete application in its own folder, /usr/local/ receives loose binaries that slot into the usual tree.
| Directory | Use | Example |
|---|---|---|
/opt/<vendor>/ | Complete, self-contained third-party application | /opt/google/chrome/, /opt/jetbrains/ |
/usr/local/bin/ | Binary compiled or downloaded by hand | In-house script, compiled Go/Rust tool |
Related guide: Manage packages.
/run/, /proc/, /sys/: volatile runtime data
These three directories are not on disk, and their contents disappear when the machine shuts down. /proc/ and /sys/ are built on the fly by the kernel. /run/ is a tmpfs (a filesystem held in RAM) that systemd and the services fill at every boot. None of the three belongs in a backup. In /run/, a service drops its PID file, which holds the number of its process, and its socket, the contact point through which other programs talk to it.
| Directory | Backed by | Contents |
|---|---|---|
/run/ | tmpfs | PID files, sockets, locks, runtime state of services |
/proc/ | procfs | Virtual view of processes and the kernel |
/sys/ | sysfs | Virtual view of the hardware and drivers |
# See a service's PID through /runcat /run/sshd.pid 2>/dev/null || echo "No PID file (service stopped or managed by systemd)"
# Read CPU information through /proccat /proc/cpuinfo | head -20
# See the total memorycat /proc/meminfo | grep MemTotal
# Read a kernel parameter through /syscat /sys/block/sda/queue/scheduler 2>/dev/nullRelated guide: Manage processes.
/home/, /root/, /srv/: user and service data
These three directories hold data, not system files, and they are the ones you back up first. The trap is in the name: /root/ is the home directory of the root account, not the root / of the tree.
| Directory | Owner | Contents |
|---|---|---|
/home/<user>/ | The user | Personal files, local config (~/.bashrc, ~/.ssh/) |
/root/ | root | Root's home directory (not to be confused with /) |
/srv/ | Services | Data served by the machine (websites, repositories, shares) |
# See how much space each user takesdu -sh /home/*/
# Check the permissions of root's home directoryls -ld /root/This separation of roles often turns into a partitioning decision. On a
multi-user server, mounting /home/ on a separate partition lets you
reinstall the system without touching account data: the reinstall
overwrites /, and /home is simply mounted again afterwards.
Related guide: Users and groups.
/dev/, /mnt/, /media/: devices and mounting
/dev/ exposes the devices as special files. /mnt/ and /media/ are mount points: the directories where the contents of a disk or a USB stick appear once it is "mounted". /mnt/ is for the administrator; /media/ receives removable media mounted automatically, on some distributions only.
| Directory | Contents |
|---|---|
/dev/ | Special files that represent devices (disks, terminals, null, random) |
/mnt/ | Temporary mount point for the administrator |
/media/ | Automatic mount point for removable media (USB, CD) on a Debian 13 desktop |
On Ubuntu 26.04, RHEL, AlmaLinux and Fedora, the automatic mounting of a workstation happens in /run/media/<user>/, a directory emptied at every reboot. Debian 13 mounts under /media/<user>/. On a server nothing is mounted by itself: you mount the media yourself, usually under /mnt/.
The device files you will meet most often in /dev/ are these:
| Device | Represents |
|---|---|
/dev/sda, /dev/sdb | SATA/SAS disks |
/dev/nvme0n1 | NVMe disk |
/dev/vda | virtio disk (KVM virtual machine) |
/dev/null | Throws away everything written to it (redirect there whatever you want to ignore) |
/dev/zero | Endless source of zeros |
/dev/random, /dev/urandom | Random number generators |
/dev/tty*, /dev/pts/* | Terminals |
# List disks and partitionslsblk
# See the available block devicesls -l /dev/sd* /dev/nvme* /dev/vd* 2>/dev/nullRelated guides: Storage overview, Identify disks, Persistent mounts.
/boot/: boot files
/boot/ contains the Linux kernel, the initramfs (the initial filesystem image, loaded before the root filesystem) and the boot loader configuration. It is a critical directory: a clumsy change can stop the system from booting.
| File | Role |
|---|---|
vmlinuz-* | Compressed Linux kernel |
initrd.img-* / initramfs-* | Initial filesystem image (drivers, LVM, encryption) |
grub/ | GRUB2 boot loader configuration |
config-* | Kernel build options |
System.map-* | Kernel symbol table (debugging) |
# See the installed kernelsls -lh /boot/vmlinuz-*
# See how much space /boot usesdf -h /bootRelated guide: Reboot and shut down.
/tmp/ and /var/tmp/: temporary files
Both directories hold temporary files, but they do not have the same lifetime, and the cleaning rules differ from one distribution to another. The type of /tmp (disk or tmpfs) was read on Ubuntu 24.04, Ubuntu 26.04, Debian 13 and AlmaLinux 10. The effect of a reboot on /tmp was tested on Ubuntu 26.04, Debian 13 and AlmaLinux 10, and is deduced from the D rule on Ubuntu 24.04. The durations come from the rules shipped with the packages; the purge itself was not tested.
| Directory | Lifetime | Cleaning |
|---|---|---|
/tmp/ | Until the next reboot on Ubuntu 24.04, Ubuntu 26.04 and Debian 13; kept on AlmaLinux 10 | Ubuntu 24.04: /tmp on disk, emptied at boot by systemd-tmpfiles (rule D). Debian 13 and Ubuntu 26.04: tmpfs in RAM, with the q … 10d rule shipped too. AlmaLinux 10: /tmp on disk and q … 10d rule (files older than 10 days purged), with no emptying at boot |
/var/tmp/ | Kept across reboots | Rule q /var/tmp 1777 root root 30d active on Debian 13, Ubuntu 26.04 and AlmaLinux 10, shipped commented out on Ubuntu 24.04 |
# Which filesystem is /tmp really on?df -Th /tmp
# See the largest temporary filesdu -sh /tmp/* 2>/dev/null | sort -rh | head -10A common explanation is not true everywhere:
"/tmp is a RAM disk, so it empties on reboot". It makes you mispredict how an
unknown machine behaves. On an Ubuntu 24.04 machine,
df -Th /tmp answers:
Filesystem Type Size Used Avail Use% Mounted on/dev/vda1 ext4 14G 2.1G 12G 16% /That is the root partition in ext4, and /tmp is not even a separate mount
point. Fedora, recent Arch and Debian 13 do mount a tmpfs, and so does Ubuntu 26.04, as the
Ubuntu Server 26.04 LTS guide
shows: hence the confusion.
A script must therefore never count on a reboot to do its cleaning for it:
depending on the distribution, /tmp is emptied at boot, or only after a few
days.
One last point about this directory, for scripts: create your temporary
files with mktemp rather than by hand. The command draws a unique
name, which avoids the collisions between two simultaneous
runs and the symlink attack, where a third party places a link at the spot
your script is about to write.
How do the directories differ between distributions?
The FHS is a standard, but each family of distributions has its own quirks. The log file names and the network configuration directory are two differences you will hit early.
| Aspect | Debian / Ubuntu | RHEL / Rocky / AlmaLinux | Alpine |
|---|---|---|---|
| System log | journalctl (/var/log/syslog with rsyslog) | /var/log/messages (rsyslog) | /var/log/messages |
| Authentication logs | journalctl (/var/log/auth.log with rsyslog) | /var/log/secure (rsyslog) | /var/log/messages |
| Package logs | /var/log/dpkg.log | /var/log/dnf.log | none |
| Network config | Ubuntu: /etc/netplan/; Debian: depends on the tool that manages the network | /etc/NetworkManager/ | /etc/network/ |
| Package config | /etc/apt/ | /etc/yum.repos.d/ | /etc/apk/ |
| Init (PID 1) | systemd | systemd | OpenRC |
| usr-merge | Yes (Debian 12+) | Yes (RHEL 9+) | No (separate) |
Mini-lab: explore the FHS on a real system
These commands change nothing on the machine. They help you check your understanding by comparing what you read with what the system actually shows.
-
Spot the functional areas
Terminal window # See the top-level directoriesls -ld /etc /var /usr /run /proc /sys /boot /tmp /home /dev /srv /opt -
Identify the configuration files of a service
Terminal window # Example with SSHls -la /etc/ssh/cat /etc/ssh/sshd_config | head -30 -
Find where a service stores its data
Terminal window # Persistent datals /var/lib/ | head -20# Logsls /var/log/ | head -20 -
Check the virtual filesystems
Terminal window # /proc and /sys are not on diskdf -Th /proc /sys /run /tmp -
Confirm usr-merge
Terminal window # On a modern distribution, /bin is a linkls -ld /bin /sbin /lib
Troubleshooting
These 6 symptoms come from a misreading of the tree, and the error message does not always say which directory is at fault. Read the left column as what you see on screen, the middle one as the hypothesis to check first, and the last one as the action that fixes the problem.
| Symptom | Likely cause | Fix |
|---|---|---|
No space left on device on /var | Logs or caches too large | du -sh /var/log/* | sort -rh, then journalctl --vacuum-size=500M or apt clean |
| systemd unit edited but not taken into account, or change gone after an update | Package file edited in /usr/lib/systemd/: an update wipes it, and a copy placed in /etc/systemd/system/ takes precedence over it. Another possible cause: systemctl daemon-reload forgotten | Create the override in /etc/systemd/system/ and run systemctl daemon-reload |
| Command not found after a manual install | Binary placed outside the PATH | Move it to /usr/local/bin/ or add its path to the PATH |
/boot full, kernel update impossible | Old kernels not purged | apt autoremove (Debian) or dnf remove --oldinstallonly (RHEL) |
| Temporary file gone after reboot | Placed in /tmp/, emptied at boot by systemd-tmpfiles (Ubuntu 24.04) or lost with the tmpfs (Debian 13, Ubuntu 26.04) | Use /var/tmp/ for files that must survive a reboot |
Permission denied on a file in /run/ | PID file or socket owned by another service | Check the owner with ls -la /run/<file>, do not change permissions by hand |
Put it into practice
The tree sticks by walking through it. The lab prepares a separate working folder on your computer, with an fhs.txt file to fill in. The commands act on your own machine, which must be a Linux (Linux computer, Ubuntu in WSL2 on Windows 11, or Linux VM): you locate four real items there, the ls command, the file that lists the local user accounts, the directory of the system logs and the directory that holds the home folders, then write their absolute path into the file. Validation checks that each path really exists where you say it does.
Key points
- The FHS organises Linux into functional areas:
/etc/for configuration,/var/for variable data,/usr/for binaries,/run/for volatile runtime data. - Three administration reflexes: config →
/etc/, problem →/var/log/orjournalctl, runtime →/run/. - Never edit a systemd unit shipped by a package (
/usr/lib/systemd/): copy it into/etc/systemd/system/to override it. /proc/,/sys/and/run/are not on disk: keep them out of your backups./tmp/is emptied at boot on Ubuntu and Debian, not on AlmaLinux 10, which only purges what is older than ten days. Use/var/tmp/for temporary files that must persist.- System logs vary with the distribution: on Debian,
rsysloghas no longer been installed by default since Debian 12, sojournalctlalone until the package is installed (thensyslogandauth.logappear);messagesandsecure, written by rsyslog, on RHEL and AlmaLinux.
Knowledge check
Check that the essentials of this guide stuck. The questions cover only what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Navigate and manage files on Linux
A new full quiz with random questions
Work again only on the questions you missed
FAQ: frequently asked questions
These are the questions that come up when you discover the tree, and they cover
costly confusions: the difference between /root and the root
/, where to put software installed by hand, and what is safe to delete
to free up space.
/ is the root of the tree: every absolute path starts there, and it contains all the other directories (/etc, /var, /usr, /home...)./root is only the home directory of the root account, the administrator's equivalent of /home/<user>. It is kept outside /home so that root still has a home directory when /home sits on a separate partition that failed to mount.ls -ld / /root
The two names sound alike, which is exactly why they get mixed up in a command: cp file /root and cp file / do not write to the same place.| Directory | Use | Example |
|---|---|---|
/usr/local/bin/ |
A loose binary or script | in-house script, compiled Go/Rust tool |
/opt/<vendor>/ |
A complete, self-contained application | /opt/google/chrome/ |
/usr/local/bin/ is already in the PATH on the reference distributions, so a binary placed there runs by its name.Never put it in /usr/bin/: that directory belongs to the package manager, which can overwrite or remove the file on the next update.df -h /var
du -sh /var/log/* | sort -rh | head
Three things can be cleaned without risk:- the package caches, with
apt clean(Debian/Ubuntu) ordnf clean all(RHEL); - the system journal, with
journalctl --vacuum-size=500M; - old rotated logs that
logrotatecompressed and kept.
/var/lib/ by hand: it holds the persistent state of services, databases and the package manager's own records. And if /boot is the full partition, remove old kernels through the package manager, never with rm./bin and /sbin held the binaries needed to boot, because /usr could live on a separate partition mounted later.On Debian 12+, Ubuntu 22.04+ and RHEL 9+, the usr-merge turned /bin, /sbin, /lib and /lib64 into symbolic links into /usr:readlink /bin /sbin
usr/bin
usr/sbin
ls /bin and ls /usr/bin therefore show the same files. Old scripts that call /bin/sh keep working, since the link resolves to the same program./proc is a virtual filesystem (procfs): the kernel computes its contents when you read them, and nothing is stored on disk.df -Th /proc /sys /run
/proc exposes the processes and the kernel (/proc/cpuinfo, /proc/meminfo), /sys the hardware and drivers, and /run is a tmpfs in memory that holds PID files and sockets.All three disappear on reboot, and all three must be excluded from backups: archiving them with tar or rsync from / causes errors or infinite loops.