Linux Filesystem
Learn how the Linux filesystem is organized, what key directories do, and how to work with absolute and relative paths.
Understanding the Linux Filesystem
One of the biggest mindset shifts for beginners is that Linux does not organize storage around drive letters like C: or D:. Instead, everything starts from a single top-level directory called the root directory, written as /.
Files, folders, devices, and even process information appear somewhere under that root. This design makes Linux systems predictable once you learn the layout.
What Is the Filesystem Hierarchy Standard?
The Filesystem Hierarchy Standard (FHS) is a convention that describes where different types of files should live on Unix-like systems. Not every distribution follows it perfectly, but most of them follow the general structure.
The goal is consistency. If configuration files are usually in /etc and logs are usually in /var/log, administrators do not have to guess where important data is stored.
Tip: Memorizing a few key directories saves time when troubleshooting a server over SSH.
The Root Directory /
The root directory is the top of the filesystem tree. Every path begins from here.
For example:
/etc/ssh/sshd_config
/var/log/syslog
/home/devops/.bashrc
Do not confuse / with the root user. The slash is the top directory. The root user is the superuser account with administrative power.
Important Linux Directories
/etc
/etc stores system-wide configuration files. You will often edit files here when managing services, users, networking, or security.
Examples:
/etc/hosts
/etc/passwd
/etc/ssh/sshd_config
In DevOps, /etc matters because many service settings are plain text and easy to automate.
/var
/var holds variable data that changes over time. This includes logs, caches, spool files, and application state.
Common examples:
/var/log/
/var/lib/
/var/cache/
When a service fails, logs in /var/log are usually one of the first places to check.
/tmp
/tmp is used for temporary files. Applications often write short-lived data here. On many systems, its contents may be cleaned automatically.
You should never store important long-term files in /tmp.
Note: In operations work, a missing file in
/tmpis often expected because cleanup jobs may remove old temporary data.
/home
/home stores personal directories for regular users.
Example:
/home/alex
/home/devops
A user’s shell profile, SSH keys, and personal scripts are often stored here.
/usr
/usr contains many user-space programs, libraries, and documentation. Despite its name, it is not only for user home data.
Common subdirectories include:
/usr/binfor commands/usr/sbinfor admin commands/usr/libfor libraries/usr/sharefor shared data and docs
/proc
/proc is a virtual filesystem that exposes kernel and process information. Files here are generated dynamically by the system rather than stored like normal files.
Useful examples:
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/1/status
This directory is valuable when diagnosing performance or understanding system state.
Absolute vs Relative Paths
A path tells Linux where a file or directory is located.
Absolute Paths
An absolute path starts with / and gives the full location from the root directory.
Example:
/home/devops/projects/app/config.yaml
No matter where you currently are in the shell, that path points to the same file.
Relative Paths
A relative path starts from your current working directory.
If you are in /home/devops/projects, then:
cd app
cat config.yaml
Here, app and config.yaml are relative paths.
Special Path Shortcuts
Linux also uses a few path shortcuts:
.means the current directory..means the parent directory~usually means your home directory
Example:
cd ~/projects
ls ../
Reading the Filesystem Like a DevOps Engineer
Suppose an Nginx service fails. A practical workflow might look like this:
cd /etc/nginx
ls
cat nginx.conf
cd /var/log/nginx
tail -n 20 error.log
This simple flow uses two key areas of the filesystem: configuration in /etc and logs in /var/log.
Another example is user troubleshooting:
cat /etc/passwd
ls /home
These commands help you see registered users and their home directories.
Why Filesystem Knowledge Matters
Filesystem knowledge is not trivia. It directly improves troubleshooting speed.
When you know where things usually live, you can:
- find config files faster
- inspect logs without guessing
- understand application layouts
- write better automation scripts
- avoid dangerous mistakes like deleting the wrong path
Beginners often struggle because Linux feels unfamiliar. The fix is repetition: navigate, inspect, and connect each directory to a real use case.
Test Your Understanding
Let's see how well you understood the concepts! These exercises will help reinforce what you just learned.
Exercise 1: Finding configuration files
Scenario: Nginx fails to start, and you want its configuration file first.
Question: Which directory from the lesson is the most likely place to check?
Exercise 1: Finding configuration files
Identify which top-level Linux directory usually stores system-wide configuration files.
Exercise 2: Reading /proc correctly
Question: What makes /proc different from a regular disk-backed directory?
Exercise 2: Reading /proc correctly
Choose the statement that correctly describes the /proc directory.
Exercise 3: Spotting a relative path
Scenario: You are currently in /home/devops/projects.
Question: Which path to config.yaml is relative rather than absolute?
Exercise 3: Spotting a relative path
Determine which example path depends on the current working directory.