Understanding the Linux Filesystem
Learn how Linux organizes files, directories, applications, logs, devices, and system data.
Difficulty: Beginner
Estimated reading time: 40 min
Introduction
One of the biggest differences between Linux and Windows is the filesystem structure.
Windows usually organizes storage around drive letters:
C:\
D:\
E:\
Linux works completely differently.
Linux uses:
A single unified filesystem hierarchy.
Everything starts from one root directory:
/
This root directory is the foundation of the entire operating system.
All files, devices, applications, logs, and mounted disks eventually exist somewhere under it.
Everything Starts From Root
In Linux, the / directory is called:
The root filesystem.
This is the highest level of the filesystem hierarchy.
Example:
/
├── home
├── etc
├── var
├── usr
└── tmp
Unlike Windows:
- Linux does not separate drives using letters
- additional disks are mounted into the filesystem
- everything becomes part of one large directory tree
This design is one of the reasons Linux systems feel extremely consistent.
Linux Filesystem Tree
A simplified Linux filesystem looks like this:
/
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
At first this structure can feel confusing.
But every directory has a specific purpose.
Linux organizes directories based on:
Function and responsibility.
Not based on application names.
Understanding Paths
Before exploring directories, it is important to understand paths.
A path describes the location of a file or directory.
There are two main types:
| Type | Example |
|---|---|
| Absolute path | /home/john/file.txt |
| Relative path | ./file.txt |
Absolute Paths
Absolute paths always start from root:
/
Example:
/home/john/projects/app.js
This path always points to the exact same location.
No matter where you currently are in the terminal.
Relative Paths
Relative paths depend on your current directory.
Example:
./app.js
../notes.txt
Symbols:
| Symbol | Meaning |
|---|---|
. |
Current directory |
.. |
Parent directory |
~ |
User home directory |
Example:
cd ..
moves one directory upward.
The Most Important Linux Directories
Now let us explore the most important directories one by one.
Understanding these directories is critical for:
- Linux administration
- DevOps
- Docker
- servers
- troubleshooting
/home
The /home directory stores personal user data.
Example:
/home/john
/home/alice
Each user typically gets their own home directory.
This is where users store:
- documents
- projects
- downloads
- SSH keys
- shell configuration files
Example:
/home/john/.bashrc
The home directory is often represented using:
~
Example:
cd ~
moves directly into the user’s home directory.
/root
This directory belongs to the root user.
Example:
/root
Do not confuse:
/
with:
/root
They are different things.
| Path | Meaning |
|---|---|
/ |
Filesystem root |
/root |
Root user’s home directory |
/etc
The /etc directory contains system configuration files.
This is one of the most important directories in Linux.
Examples:
/etc/nginx/nginx.conf
/etc/ssh/sshd_config
/etc/passwd
This directory often controls system behavior.
When configuring Linux services, you will constantly work inside /etc.
Why Plain Text Configurations Matter
Linux heavily uses plain text configuration files.
This is extremely powerful because:
- configurations are readable
- configurations are scriptable
- configurations are easy to version control
- automation becomes simple
Example Nginx config:
server {
listen 80;
server_name example.com;
}
You can modify infrastructure using simple text files.
That idea is deeply connected to DevOps culture.
/var
The /var directory stores:
Variable data.
This includes data that constantly changes while the system runs.
Examples:
/var/log
/var/cache
/var/lib
/var/log
This directory stores system and application logs.
Examples:
/var/log/syslog
/var/log/nginx/
/var/log/auth.log
Logs are critical for:
- debugging
- monitoring
- troubleshooting
- security investigations
When something breaks on Linux:
Logs are usually the first place you investigate.
/var/lib
Applications often store internal application data here.
Examples:
/var/lib/docker
/var/lib/mysql
Docker stores containers, images, and volumes inside:
/var/lib/docker
This directory becomes extremely important in DevOps environments.
/tmp
The /tmp directory stores temporary files.
Applications use it for:
- temporary data
- caches
- intermediate processing
Example:
/tmp/upload.tmp
Files inside /tmp are often automatically cleaned during reboot.
Never store important permanent data here.
/usr
The /usr directory contains:
- applications
- libraries
- utilities
- documentation
This is one of the largest directories in Linux systems.
Examples:
/usr/bin
/usr/lib
/usr/share
/usr/bin
Contains many user commands and executables.
Examples:
/usr/bin/python
/usr/bin/git
/usr/bin/docker
When you execute commands, many of them come from directories like:
/usr/bin
/bin
Contains essential system binaries.
Examples:
/bin/ls
/bin/cp
/bin/mv
These commands are required even during minimal system boot environments.
Historically /bin and /usr/bin were separated for boot reasons.
Modern systems sometimes merge them internally.
/sbin
Contains system administration binaries.
Examples:
/sbin/reboot
/sbin/fsck
These commands are usually intended for administrative tasks.
/dev
This directory is one of the most fascinating parts of Linux.
Remember the Linux philosophy:
Everything is a file.
In Linux, hardware devices can appear as files.
Examples:
/dev/sda
/dev/null
/dev/random
Example: Hard Drives
A disk may appear as:
/dev/sda
Partitions:
/dev/sda1
/dev/sda2
Applications communicate with hardware through these device files.
/dev/null
One of the most famous Linux special files:
/dev/null
Anything written into it disappears forever.
Example:
echo hello > /dev/null
Output is discarded.
This is commonly used in scripting.
/proc
The /proc directory is a virtual filesystem.
It does not store real files on disk.
Instead, it exposes live kernel and process information.
Examples:
/proc/cpuinfo
/proc/meminfo
Example: CPU Information
cat /proc/cpuinfo
displays detailed CPU information directly from the kernel.
This is one of the reasons Linux feels extremely transparent.
The operating system exposes internal system information directly through files.
/boot
Contains files required during system startup.
Examples:
/boot/vmlinuz
/boot/grub
This includes:
- kernel images
- bootloader files
- startup configurations
Without /boot, the operating system cannot start properly.
/mnt and /media
These directories are commonly used for mounted devices.
Examples:
/mnt/backup
/media/usb
External drives and USB devices are often mounted here.
Mounting in Linux
Linux does not access disks using drive letters.
Instead:
Filesystems are mounted into directories.
Example:
/dev/sdb1 → /mnt/storage
After mounting, the disk becomes accessible through:
/mnt/storage
This is fundamentally different from Windows.
File Extensions in Linux
Linux does not rely heavily on file extensions.
In Windows:
.exe
.jpg
.txt
often determine file behavior.
In Linux:
- permissions matter more
- file content matters more
- executability matters more
Example:
script.sh
does not become executable automatically.
You must explicitly allow execution:
chmod +x script.sh
Hidden Files
Files beginning with . are hidden.
Examples:
.bashrc
.gitconfig
.env
These files are usually:
- configuration files
- environment files
- user preferences
Symbolic Links
Linux supports symbolic links.
A symbolic link points to another file or directory.
Example:
ln -s /var/log logs
This creates:
logs → /var/log
Similar to shortcuts in Windows.
But much more integrated into the filesystem itself.
Why Linux Filesystems Feel Different
Windows often organizes files around:
- applications
- GUI installers
- drive letters
Linux organizes files around:
- purpose
- system architecture
- standardization
This consistency makes Linux systems:
- easier to automate
- easier to script
- easier to manage at scale
That is one reason Linux dominates servers and infrastructure.
Real-World Example
Imagine installing Nginx.
You may encounter:
| Path | Purpose |
|---|---|
/etc/nginx |
Configuration |
/var/log/nginx |
Logs |
/var/www/html |
Website files |
/usr/sbin/nginx |
Nginx executable |
Linux separates responsibilities clearly.
This structure becomes incredibly useful once systems grow larger.
The Most Important Thing to Understand
The Linux filesystem is not random.
Every directory exists for a reason.
Once you understand:
- where configs live
- where logs live
- where executables live
- where application data lives
Linux suddenly becomes much easier to navigate.
At that point, the operating system starts feeling logical instead of confusing.
What Comes Next
In the next chapter, we will learn how to:
- navigate the filesystem
- manage files and directories
- copy and move files
- search for files
- work efficiently from the terminal