Basic Linux File Folders

If you are new to Linux, the file system structure can initially seem confusing. Unlike Windows, which organizes files using separate drives (C:, D:, etc.), Linux uses a single hierarchical tree with everything stemming from the root (/) directory.

Each folder inside / has a specific role, and understanding these roles can make troubleshooting, system management, and daily tasks easier. In this post, I will explain the 10ish important directories in Linux, explaining their purpose and contents in detail.


1. / - The Root Directory

What it does:

  • The root directory (/) is the top-level directory in the Linux file system. Everything in Linux is stored inside this directory, whether they are files, folders, or mounted devices.
  • It contains all other directories, forming the base of the Linux file hierarchy.

Why it matters:

  • Unlike Windows, where programs and files can be scattered across multiple drives, Linux organizes everything under /.
  • When you install Linux, this structure is created automatically.
  • If you delete or corrupt files inside /, your system may become unusable.

2. /home - User Home Directories

What it does:

  • The /home directory contains personal directories for each user on the system.
  • For example, if your username is john, your personal files are stored in /home/john/.

What’s inside:

  • Personal files: Documents, downloads, pictures, music, videos, etc.
  • Configuration files: Hidden “dotfiles” (like .bashrc or .profile) that store user-specific settings.
  • User-specific applications: Some apps store user data in directories like ~/.config/ or ~/.local/share/.

Why it matters:

  • Unlike Windows, where user data is stored in C:\Users\, Linux keeps everything neatly inside /home.
  • If you reinstall Linux, you can keep your /home directory separate so you do not lose personal data.
  • This is why it is recommend that your home directory is created on its own partition.

3. /root - The Root user Home Directory

What it does:

  • /root is the home directory for the root user (the superuser or administrator).
  • It is separate from regular user directories (/home/username/).

What’s inside:

  • Root user-specific files and settings.
  • This folder contains system administration scripts or commands only accessible by the root user.

Why it matters:

  • Regular users are restricted from the folder /root, preventing them from making critical system changes.
  • If you log in as root (not recommended for daily use), this is where your personal files would be.

4. /etc - System Configuration Files

What it does:

  • This directory stores system-wide configuration files that control how Linux behaves.
  • Most applications and services have their settings stored here.

What’s inside:

  • Network settings: /etc/network/interfaces (network configuration), /etc/hosts (local hostnames).
  • User authentication files: /etc/passwd (user accounts), /etc/shadow (encrypted passwords).
  • Service configurations: Web servers, SSH settings, firewall rules, etc.

Why it matters:

  • If you want to change system settings, these files are found in the /etc folder, where you will edit them.
  • Modifying some of these files can break your system, so always make backups before editing.

5. /bin and /sbin - Essential System Programs

What they do:

  • /bin/ (binaries) and /sbin/ (system binaries) store essential programs that let you interact with Linux.

What’s inside /bin/:

  • Basic commands available to all users, like:
    • ls (list files)
    • cp (copy files)
    • rm (remove files)
    • cat (view file contents)

What’s inside /sbin/:

  • System administrator commands, like:
    • shutdown (turn off the system)
    • fdisk (manage disk partitions)
    • iptables (configure firewalls)

Why they matter:

  • These directories contain fundamental Linux tools required to run the system.
  • Without /bin/, you could not execute basic commands like the ones listed above.

6. /var - Variable Data (Logs, Caches, Databases)

What it does:

  • Stores files that change frequently, such as logs, cache files, and mail queues.

What’s inside:

  • Logs: /var/log/ contains system logs (syslog, auth.log, etc.).
  • Web server files: /var/www/ stores website files if you run a web server.
  • Print and mail files: /var/spool/ contains print queues and email processing data.

Why it matters:

  • If your server is suffering from unexplained issues, checking logs in /var/log/ can help pinpoint the problem(s).
  • If /var/ fills up, it can cause services to fail (e.g., an overfull log partition might crash a web server).

7. /usr - User-installed Programs and Libraries

What it does:

  • Contains applications and libraries that users install manually or via package managers.

What’s inside:

  • /usr/bin/: Most common Linux programs (e.g., nano, git, firefox).
  • /usr/local/: Custom software installed by the user (not managed by the OS).

Why it matters:

  • If you install software manually, you will often find it in /usr/local/bin/.
  • Unlike /bin/ (which holds system-critical commands), /usr/bin/ is for user applications.

8. /tmp - Temporary Files

What it does:

  • Stores temporary files that are automatically deleted when the system reboots.

What’s inside:

  • Temporary user files.
  • Session data for running applications.

Why it matters:

  • Useful for storing temporary downloads or test files.
  • Do not store important files here—they will be erased on reboot!

9. /mnt and /media - Mount Points for External Drives

What they do:

  • These directories are used for mounting internal or external drives (USBs, CDs, network drives).

What’s inside:

  • /mnt/: A generic folder where you can manually mount devices.
  • /media/: Used by the system to auto-mount removable storage (e.g., /media/usbdrive).

Why they matter:

  • If you plug in a USB drive and it does not appear in /media/, you might need to mount it manually.

Example:

sudo mount /dev/sdc1 /mnt/usb

10. /dev, /proc, and /sys - System and Hardware Information

/dev/ - Device Files

  • Contains files representing hardware devices, like:
    • /dev/sda (primary hard drive)
    • /dev/usb0 (USB devices)

/proc/ - Process Information

  • Contains real-time system info, such as:
    • /proc/cpuinfo (CPU details)
    • /proc/meminfo (memory usage)

/sys/ - Kernel and Hardware Settings

  • Provides a way for the system to interact with hardware components.

Why they matter:

  • Need to check system info? (cat /proc/cpuinfo), These directories are invaluable.
  • /dev/ is crucial for mounting drives and accessing hardware.

Wrapping Up

The Linux file system might seem complex, but once you understand the role of each folder, it becomes much easier to navigate and manage. The more you explore, the more comfortable you will become.

If you are new to Linux, try using the ls command to look inside each folder. For example:

ls /
ls /etc
ls /usr/bin

This hands-on approach will help reinforce what you have learned. Happy exploring.