Linux File Structure: A Practical Map of the Filesystem
A beginner-friendly guide to the important Linux directories, what belongs in each one, and the commands that help you navigate safely.
Linux does not organize storage around drive letters. It presents one directory tree that begins at /, called the root directory. Other disks, partitions, and remote filesystems are attached somewhere inside that tree through mount points.
You do not need to memorize every directory to work comfortably on Linux. A useful mental model is to learn which directories hold personal files, configuration, changing application data, and the operating system itself.
The top-level map
/
├── bin -> usr/bin
├── boot
├── dev
├── etc
├── home
├── lib -> usr/lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin -> usr/sbin
├── srv
├── sys
├── tmp
├── usr
└── var
Some current distributions use a merged layout where directories such as /bin, /sbin, and /lib are symbolic links into /usr. The paths are still valid; the links simply keep older software compatible with the newer layout.
The directories you use most
/home: users’ personal files
Each normal user usually has a home directory such as /home/alex. Documents, source code, shell configuration, SSH configuration, and application settings live here.
The shortcut ~ means the current user’s home directory. For example, ~/projects is more portable than writing a specific home path into a script.
/etc: system configuration
/etc contains host-wide configuration: users and groups, services, network settings, scheduled jobs, and package configuration. Files here are generally plain text, which is one reason Linux systems are easy to inspect and automate.
Before changing a configuration file, make a backup and understand which service reads it. A syntactically correct file can still make a service fail if a required setting is removed.
/var: changing application data
The name comes from “variable.” Logs, caches, queues, package databases, and service data commonly live under /var.
Useful locations include:
/var/log: system and application logs./var/lib: persistent state managed by services./var/cache: data that can usually be recreated./var/tmp: temporary files that may survive a reboot longer than/tmp.
When a server runs out of space, /var is one of the first places worth investigating.
/usr: installed operating-system software
/usr contains most user-space programs and shared read-only data installed by the distribution or a package manager.
/usr/bin: regular command-line programs./usr/sbin: administrative commands./usr/lib: libraries used by installed programs./usr/share: architecture-independent documentation, locales, and data./usr/local: software installed by the system administrator rather than the package manager.
The name does not mean these files belong to one particular user. It is part of the standard Unix filesystem layout.
Special virtual filesystems
Some directories look like ordinary folders but expose live kernel or process information.
/dev: device nodes such as disks, terminals, and random-number devices./proc: process and kernel information exposed as files./sys: hardware and kernel device information./run: short-lived runtime state created since boot.
These locations are not normal places for application data. Their contents can change while you are looking at them, and many files are readable but not writable by regular users.
Boot, temporary, and mounted storage
/bootcontains the kernel and bootloader files needed to start the system./tmpis for temporary files. Programs should not assume that files there will remain forever./mediais commonly used for automatically mounted removable media./mntis a conventional place for temporary or manually mounted filesystems./optis often used for optional, self-contained third-party software./srvcan hold data served by system services, such as a web server’s content./rootis the home directory of therootadministrator, not the filesystem root itself.
Navigating safely
These commands answer most day-to-day questions:
# Show the current directory
pwd
# List visible and hidden entries with readable sizes
ls -lah
# Find the size of the current directory's immediate children
du -h --max-depth=1 .
# Show free space on mounted filesystems
df -h
# Find a file by name below the current directory
find . -name "settings.json"
du measures how much space a directory’s contents use. df measures free space on the filesystem that contains a path. If those numbers seem different, remember that deleted files can still consume space while a process has them open.
Use absolute paths when a script must act on a specific location, and quote paths that may contain spaces:
cp "$HOME/notes/today.md" "$HOME/archive/"
Permissions and ownership
Every path has an owner, a group, and permission bits for the owner, group, and everyone else. Read, write, and execute permissions mean different things for directories: execute allows traversal, while read allows listing their entries.
ls -ld /etc /home "$HOME"
stat "$HOME/notes/today.md"
Avoid using sudo as a default. It is appropriate for a system-level change, but using it for everyday work can create root-owned files in your home directory and hide the real permission problem.
Where should application files go?
For a personal project, keep source code in your home directory, such as ~/projects/weather-app. For a service installed for the whole machine, follow the application’s packaging guidance; /opt, /usr/local, /var/lib, and /etc each have different purposes.
Do not place long-lived files in /tmp, do not edit files under /usr by hand when a package manager owns them, and do not treat /root as a shortcut for /.
The Linux filesystem becomes much less mysterious when each directory is treated as a promise: /etc describes configuration, /var records changing state, /home belongs to users, and /usr provides installed software. Learn those boundaries first, then explore the rest as needed.