Understanding Linux Directory Structure

Cloud DevOps Minimals
3 min readMay 7, 2023

--

The Linux directory structure, sometimes called the Filesystem Hierarchy Standard (FHS), is a way to organize files and folders in a Linux operating system. It helps to keep things organized and easy to find across different versions of Linux.

In Linux, everything starts with the root directory, which is shown as a single forward slash (“/”). From there, you’ll find many other folders, each with a special job. These folders hold things like system files, settings, user files, and other important pieces that help Linux run smoothly.

Understanding the Linux directory structure is crucial for system administration tasks and general file management, as it enables users to locate, manage, and organize files efficiently”

Top-Level Directory (/)

The top directory containing all other directories and files.

/bin

Stores binary files related to system functions.

  • Examples/Usage: mount, ls, rm, cp, etc.
  • Example Commands: ls, cp, mkdir, grep

/boot

Contains files related to the boot process.

  • Examples/Usage: Kernel files, bootloader, initramfs
  • Example Files: vmlinuz, initrd.img, grub.cfg

/dev

Holds information about connected devices.

  • Examples/Usage: Hard drives, USB devices, terminal devices
  • Example Files: /dev/sda, /dev/tty1

/etc

Contains configuration files for Linux and its applications.

  • Examples/Usage: passwd, fstab, network configuration files, Apache configs
  • Example Files: /etc/fstab, /etc/hosts, /etc/passwd

/home

Each user has a separate folder in this user directory.

  • Examples/Usage: User data, personal settings, documents
  • Example Directories: /home/username

/lib

Stores library files.

  • Examples/Usage: Shared libraries, kernel modules
  • Example Files: /lib/libc.so, /lib/modules/

/lost+found

Used by fsck (filesystem check) to store recovered files.

  • Examples/Usage: Orphaned files recovered after a filesystem check

/media

Used as a mount point for external media like CD/DVD ROMs.

  • Examples/Usage: CD-ROMs, DVDs, external hard drives
  • Example Directories: /media/cdrom, /media/usb

/mnt

Used for temporarily mounted devices like network shares.

  • Examples/Usage: Network filesystems, temporary storage devices
  • Example Directories: /mnt/nfs_share, /mnt/temp_drive

/opt

Contains files not managed by the package manager.

  • Examples/Usage: Third-party software, optional packages
  • Example Directories: /opt/google/chrome, /opt/skype

/proc

A virtual filesystem providing system details.

  • Examples/Usage: Process information, hardware status, kernel settings
  • Example Files: /proc/cpuinfo, /proc/meminfo

/root

Home directory for the root user.

  • Examples/Usage: Root user’s personal files and settings
  • Example Files: /root/.bashrc

/sbin

Stores binary files that can be run by the superuser only.

  • Examples/Usage: System administration commands like fdisk, ifconfig
  • Example Commands: fdisk, ifconfig, reboot, shutdown

/selinux

Stores information about Security Enhanced Linux (not present in some distributions).

  • Examples/Usage: SELinux policy files, security contexts
  • Example Files: /selinux/policy

/srv

Stores data services used by the system.

  • Examples/Usage: Web server data, FTP server data
  • Example Directories: /srv/www, /srv/ftp

/sys

Contains information related to the Linux system.

  • Examples/Usage: System devices, kernel data structures
  • Example Directories: /sys/devices

/tmp

Used as a temporary folder for applications.

  • Examples/Usage: Temporary files created by applications, session data

/usr

Stores user utilities and applications.

  • Examples/Usage: User programs, libraries, documentation, and source code
  • Example Directories: /usr/bin, /usr/share, /usr/lib

/var

Stores variable data files.

  • Examples/Usage: Log files, spool files, databases, cached files, web content
  • Example Directories: /var/log, /var/spool, /var/cache

--

--