Linux filesystem hierarchy

4.3 Where Data is Stored (Weight: 3)

📘Linux Essentials (LPI 010-160)


1. Root Directory (/)

  • The top-level directory in Linux.
  • All other directories and files are under /.
  • Examples of important directories under / will be discussed below.

2. /bin – Essential User Binaries

  • Contains essential command-line programs needed for basic tasks.
  • Programs in /bin can be used even in single-user mode (recovery mode).
  • Examples:
    • ls – list files
    • cp – copy files
    • mv – move files
    • cat – view file content

Exam Tip: Remember /bin contains essential commands for all users.


3. /sbin – System Binaries

  • Contains system programs used mainly by the system administrator (root).
  • Used for system maintenance and administration.
  • Examples:
    • ifconfig – manage network interfaces
    • reboot – reboot the system
    • fdisk – manage disk partitions

Exam Tip: /sbin = admin commands.


4. /etc – Configuration Files

  • Contains system-wide configuration files.
  • Almost all programs store their configurations here.
  • Examples:
    • /etc/passwd – stores user account information
    • /etc/fstab – filesystems to mount at boot
    • /etc/ssh/sshd_config – SSH server settings

IT Example: If an IT admin wants to change network settings, they might edit /etc/network/interfaces.


5. /home – User Home Directories

  • Each user has a personal directory under /home.
  • Stores user files and personal settings.
  • Example:
    • /home/pooja/ – files for the user pooja

IT Example: Developers store their project files under their /home directories.


6. /root – Root User Home

  • This is the home directory for the root user (the superuser).
  • Different from /home.
  • Example: /root/.bashrc stores root’s shell settings.

7. /lib – Essential Libraries

  • Stores shared libraries needed by programs in /bin and /sbin.
  • Libraries are like “helper files” for programs to run.
  • Examples:
    • libc.so.6 – core system library
    • libm.so – math functions

Exam Tip: /lib is for essential libraries for basic system operation.


8. /usr – User Programs and Data

  • Contains user applications and utilities that are not essential for booting.
  • Subdirectories:
    • /usr/bin – non-essential user programs (e.g., vim, firefox)
    • /usr/sbin – admin programs for non-critical system tasks
    • /usr/lib – libraries for /usr/bin and /usr/sbin
    • /usr/share – shared data like icons, documentation, fonts

IT Example: Software installed from the package manager usually goes here.


9. /var – Variable Data

  • Contains files that change frequently.
  • Examples:
    • /var/log – system logs
    • /var/mail – user emails
    • /var/spool – print jobs or scheduled tasks

IT Example: Checking /var/log/syslog helps troubleshoot system errors.


10. /tmp – Temporary Files

  • Used for temporary files created by users or programs.
  • Files in /tmp are deleted on reboot on many systems.

11. /dev – Device Files

  • Represents hardware devices like disks, USB drives, printers.
  • Files in /dev are special interfaces to devices.
  • Examples:
    • /dev/sda – first hard drive
    • /dev/tty – terminal devices

IT Example: Mounting a USB drive uses /dev/sdb1 as the device file.


12. /mnt and /media – Mount Points

  • /mnt – temporary mount points for manual mounting.
  • /media – used for removable media like USB drives or CDs.
  • Example: /media/usbdrive/ for a USB stick.

13. /boot – Boot Loader Files

  • Contains files required to boot Linux.
  • Examples:
    • Kernel files: vmlinuz
    • Bootloader configs: grub/

Exam Tip: /boot is critical for booting; don’t delete files here.


14. /opt – Optional Software

  • Used for third-party or optional software.
  • Often used by commercial software.
  • Example: /opt/google/chrome/

15. /proc – Process and Kernel Information

  • A virtual filesystem that provides info about running processes and kernel.
  • Example:
    • /proc/cpuinfo – CPU details
    • /proc/meminfo – memory details

IT Example: Admins check /proc to monitor system hardware and performance.


16. /sys – System Files

  • Another virtual filesystem for kernel and hardware information.
  • Mostly used by the system, scripts, and administrators.

Quick Reference Table for Exams

DirectoryPurposeExample Use
/Root directoryTop of filesystem
/binEssential commandsls, cp
/sbinAdmin commandsfdisk, reboot
/etcConfiguration filespasswd, ssh/sshd_config
/homeUser directories/home/pooja/
/rootRoot user home/root/.bashrc
/libEssential librarieslibc.so.6
/usrUser programs/usr/bin/vim
/varVariable dataLogs, mail
/tmpTemporary filesTemp files by programs
/devDevice files/dev/sda, /dev/tty
/mntMount pointsManual mounts
/mediaRemovable mediaUSB drives
/bootBoot filesKernel, GRUB
/optOptional softwareThird-party apps
/procProcess info/proc/cpuinfo
/sysSystem infoKernel data

Key Points for the Exam

  1. All Linux files and directories start at /.
  2. /bin and /sbin are for essential commands; /usr is for additional programs.
  3. Configuration files are mostly in /etc.
  4. User data is in /home.
  5. Logs and dynamic data are in /var.
  6. Device files live in /dev.
  7. Temporary files in /tmp.
  8. Virtual filesystems /proc and /sys provide system info without using real disk space.
  9. /opt is optional, /boot is critical for booting.

This content covers everything you need for the Linux filesystem hierarchy section of LPI 010-160.

Buy Me a Coffee