DEV Community

Cover image for Linux Filesystem: Understanding the Core Structure (Day 1 of 30)
Sheikh Hassaan Bin Nadeem
Sheikh Hassaan Bin Nadeem

Posted on

3

Linux Filesystem: Understanding the Core Structure (Day 1 of 30)

Table of Contents


1. Introduction

The Linux filesystem forms the backbone of how data, applications, and services are organized on any Linux-based system. Whether you're working as a system admin, cloud engineer, or DevOps practitioner, knowing where everything lives is a critical first step in becoming comfortable with Linux.

File System Hierarchy

2. Linux Filesystem Breakdown

/ – Root Directory

What it is:

The root (/) is the top-level directory in the Linux hierarchy. Everything begins here & every other directory branches from this point.

Use Case:

All filesystems are mounted under this directory. It’s your starting point when navigating the system via the command line.

Why It Matters:

Understanding that everything flows from / helps you avoid confusion when navigating or scripting in Linux.

Pro Tip:

Avoid writing files directly in /. It's reserved for system-level folders, not user data.


/home – User Home

What it is:

Contains personal directories for each user (e.g., /home/ali). This is where user files, settings, and custom configurations are stored.

Use Case:

A developer or system user keeps all project files, downloads, and personal shell settings here.

Why It Matters:

Keeps user data isolated from system files, reducing the risk of accidental system changes.

Pro Tip:

Set up disk quotas or backups per /home/username to manage user storage effectively.


/root – Superuser’s Space

What it is:

This is the root user’s personal directory, separate from other users for security reasons.

Use Case:

System administrators use this when logged in as root to perform high-privilege tasks.

Why It Matters:

Segregates critical administrative tasks from regular user operations.

Pro Tip:

Avoid using the root account directly unless absolutely necessary. Use sudo instead.


/bin and /sbin – Essential Binaries

What it is:

  • /bin: Basic commands available to all users (e.g., cp, mv, ls).
  • /sbin: System-level commands for admins (e.g., shutdown, mount, ip).

Use Case:

Commands stored here are used during both normal operations and system recovery.

Why It Matters:

These are available even if other directories like /usr are not mounted during boot.

Pro Tip:

Use which or whereis to locate command binaries and verify where they’re stored.


/etc – Configurations

What it is:

Holds all system-wide configuration files for services, applications, and system settings.

Use Case:

Edit files like /etc/ssh/sshd_config to configure the SSH server.

Why It Matters:

This is where the brain of your system lives in terms of how it behaves.

Pro Tip:

Always back up config files before modifying them. Use version control if possible.


/usr – Shared User Resources

What it is:

Contains user-facing programs and libraries. Think of it as a second root for user applications.

Use Case:

Software installed from repositories often lives here (/usr/bin, /usr/lib).

Why It Matters:

Separates core OS files from user-installed applications and documentation.

Pro Tip:

Don’t confuse /usr with /home: this is for shared resources, not individual user data.


/opt – Optional Software

What it is:

Used for manually or third-party installed software that doesn’t come from package managers.

Use Case:

Installing a custom monitoring tool or analytics dashboard.

Why It Matters:

Keeps your manual installs from cluttering system directories.

Pro Tip:

Use this for organizing non-standard apps like Java, ElasticSearch, etc.


/tmp – Temporary Storage

What it is:

A scratch space for temporary files. Often cleared on reboot.

Use Case:

Used by applications or users to store temporary runtime data.

Why It Matters:

Helps avoid clutter in main directories and improves app performance.

Pro Tip:

Never store critical data here. It could be wiped after a restart.


/proc – Process Info

What it is:

A virtual filesystem containing runtime system information and process data.

Use Case:

Check system resources (/proc/cpuinfo, /proc/meminfo) or inspect running processes.

Why It Matters:

Provides a real-time window into system operations.

Pro Tip:

You can read from it like a file using cat, e.g., cat /proc/uptime.


/var – Logs and Runtime Data

What it is:

Contains files that frequently change: logs, caches, mail, etc.

Use Case:

Monitor logs (/var/log/syslog, /var/log/auth.log) to debug errors.

Why It Matters:

Critical for system monitoring, troubleshooting, and auditing.

Pro Tip:

Set up log rotation and monitoring alerts on this directory.


/dev – Device Interfaces

What it is:

Represents hardware devices as files (e.g., /dev/sda for a hard disk).

Use Case:

Mount USB drives or interact with hardware components directly.

Why It Matters:

Allows Linux to treat everything as a file—including hardware.

Pro Tip:

Use lsblk or fdisk -l to safely explore connected devices.


3. Summary

  • The Linux filesystem is logically structured, and each directory has a specific role.
  • Mastering it gives you control, confidence, and clarity while working on servers or embedded systems.
  • This foundational knowledge will help in upcoming topics like user management, permissions, and system troubleshooting.

Top comments (0)