Skip to content

Linux Directory Layout: Where Configuration, Logs, and Data Live: A Beginner Guide

Admin
October 19, 2026
12 min read
Beginner
💻 Target OS: Ubuntu 24.04+ / Debian 12+ / RHEL 9+

Before you begin

  • Applies to:Linux systems with Bash and common coreutils and util-linux commands.
  • Where to start:Open Bash with your regular account on the system you want to inspect.
  • What you need:Have a path in mind if you are looking for a particular file. Minimal installations and containers may omit some directories.
Guide tools
Guide tools
0/0 Steps (0%)

A path tells you both where something is located and, by convention, what role it serves. This guide extends the directory introduction in filesystems and mounts with a practical tour of configuration, application state, executable files and runtime data.

These commands inspect paths without changing files or mounts. A permission error is a reason to check access before running a command with more privileges.

Configuration, persistent application data and volatile runtime data have different directory roles.

01

Distinguish the Filesystem Root from the Root Account

Orientation

The single slash names the top of the directory tree. The root account is a privileged user, while /root is commonly that account’s home directory. Inspect directory metadata without attempting to enter another user’s home. Your current working directory is independent of your own home directory.

Terminal window
pwd
printf 'Your home directory: %s\n' "$HOME"
ls -ld / /root "$HOME"
02

Recognize the Main Directory Roles

Practice

List the common top-level directories. A directory may itself be a mount point or contain paths mounted from other filesystems. The path name describes its intended role; it does not identify a physical disk or prove that data is backed up.

Terminal window
ls -ld /etc /usr /var /home /run /tmp /opt
findmnt -T /var
LocationUsual purposeBeginner rule
/etcHost and service configurationInspect the application documentation before editing.
/usrDistribution-managed software and shared resourcesUse the package manager for managed files.
/usr/local, /optLocally installed or additional softwareFollow the installation’s ownership and upgrade model.
/var/libPersistent application stateTreat databases and service data as application-owned.
/var/logLogs and, on some hosts, persistent journalsUse the intended reader and retention policy.
/runVolatile runtime informationDo not use it for a durable backup.
/homeRegular users’ home directoriesRespect ownership and private content.
/tmp, /var/tmpTemporary working dataAssume cleanup policies may remove files.
03

Find Configuration Under /etc

Practice

Inspect directory entries without printing secrets. The os-release file is a useful harmless example and may be a symlink into /usr/lib. Configuration may also use drop-in directories, includes, a database or a remote control plane; one file does not necessarily represent the complete effective configuration.

Terminal window
ls -ld /etc
ls -l /etc/os-release
cat /etc/os-release
04

Locate Programs and Shared Software

Practice

Find the program selected by your current shell and inspect common software directories. On many current distributions /bin and /sbin are symlinks into /usr. Follow what the host actually uses instead of relocating files to match a diagram. Software in /opt may have its own layout.

Terminal window
command -v ls
type -a ls
ls -ld /bin /sbin /usr/bin /usr/sbin /usr/local /opt
05

Separate Application State, Logs and Cache

Practice

These directories hold different types of variable data. A database under /var/lib requires application-aware backup and restore. Cached data may be regenerable, but deleting it can still disrupt a service. Logs may be files, journal entries or forwarded records, depending on the host.

Terminal window
ls -ld /var/lib /var/log /var/cache
findmnt -T /var/lib
findmnt -T /var/log
06

Identify Volatile Runtime and Temporary Storage

Practice

Inspect filesystem type and permissions for /run and temporary locations. Runtime PID files and sockets are often stored under /run. /tmp may be memory-backed or disk-backed. /var/tmp is intended for longer-lived temporary work, but local cleanup policy still matters. None of these locations is an approved place for your only backup copy.

Terminal window
ls -ld /run /tmp /var/tmp
findmnt -T /run
findmnt -T /tmp
findmnt -T /var/tmp
07

Recognize Kernel Interfaces and Device Nodes

Practice

The /proc and /sys trees expose process, kernel and device information through virtual filesystems. /dev contains device nodes and other special entries. Reading ordinary metadata differs from writing a control file or a device. Do not experiment with redirection into these trees.

Terminal window
ls -ld /proc /sys /dev
findmnt -T /proc
findmnt -T /sys
findmnt -T /dev
08

Understand Mount and Served-Data Locations

Practice

The /mnt and /media conventions help organize mounted storage; /srv can hold data served by the host. Applications and organizations may choose other documented paths. Inspect each existing location and the filesystem beneath it. This loop reports absent directories without trying to create or mount anything.

Terminal window
for location in /mnt /media /srv; do
if [ -d "$location" ]; then
ls -ld -- "$location"
findmnt -T "$location"
else
printf 'Not present on this host: %s\n' "$location"
fi
done
09

Map a Service to Its Declared Directories

Connect the Concepts

On a systemd host, inspect the journald unit as a read-only example. The properties can show a unit file and explicitly declared storage directories. Empty properties do not prove that the program uses no files; applications can choose paths independently. Containers and systems without systemd may not support this inspection.

Terminal window
# Optional: only on a systemd host with this unit installed.
systemctl show systemd-journald.service \
--property=FragmentPath --property=StateDirectory \
--property=CacheDirectory --property=LogsDirectory --property=RuntimeDirectory
10

Choose the Right Next Procedure

Review

Identify the software that owns the path, its documented purpose, the actual mount and the account allowed to manage it. Configuration edits, capacity cleanup, application backups and storage changes need different procedures. This tour created no files and changed no mounts, so there is no lab cleanup.

References: systemd file hierarchy, the installed hier(7) manual, and filesystem mounts. Continue with safe configuration editing or filesystem and mount basics.

Comments