Linux Directory Structure Made Easy

Aniket RajeAniket Raje
12 min read

When I first tried Linux, the folders confused me a lot.
I saw names like /etc, /bin, and /usr, and I had no idea what they were.

On Windows, you usually see a C: drive with folders like Program Files and Documents.
Linux is different—everything is inside one big tree that starts with / (called “root”).


💡 If you’ve ever looked at those strange folders and thought:

“What do these even mean?”

This guide will help.
I’ll explain the Linux file system step by step, using simple words and examples you can test on your own computer.


🐧 Linux File System Hierarchy

In Linux, everything is represented as a file — including programs, devices, and hardware.
All files are organized inside directories, and these directories are arranged in a tree-like structure, known as the File System Hierarchy.


Key Points

  • Linux uses a single-rooted, inverted tree structure.
  • The root directory is represented by / (forward slash).
  • / is the top-level directory, from which all other files and directories branch out.

Structure Overview

Linux File System Hierarchy


/ – The Root Directory

  • The root directory is the topmost level of the Linux File System Hierarchy (FSH).
  • Every other directory in Linux originates from this single directory.
  • It is represented by a forward slash /, and serves as the starting point of the entire file system.
  • So, if someone says “look into the slash directory”, they are referring to the root directory (/) itself.

Example:

$ ls /
bin   etc   home   lib   root   tmp   usr   var

Here, you can see that all major system directories like /bin, /etc, /home, /usr, /var, etc exist under the root / directory.


/root – Home Directory of the Superuser

  • The /root directory is the home directory of the root user (also known as the superuser).
  • It is different from /, which is the root of the entire filesystem.
  • By default, all configuration files, scripts, and data specific to the root user are stored here.
  • Only the root user has access to this directory. Regular users cannot access it unless they use sudo or have explicit permissions.

Example:

$ echo $HOME
/home/aniket   # For a normal user  

$ sudo su
# echo $HOME
/root            # For the root (superuser)

Here, you can see that normal users have their home directory under /home/username, while the superuser’s home is located at /root.


/home – User Home Directories

  • The /home directory contains the home directories for all regular (non-root) users on the system.
  • Each user gets their own subdirectory under /home.
  • Example:
    • /home/aniket → Home directory of user Aniket.
  • Inside each user’s home directory, you’ll typically find:
    • Personal files (Documents, Downloads, Music, etc.)
    • Configuration files (often hidden, like .bashrc, .profile)
  • Unlike /root (superuser’s home), /home is for normal users.

Example:

$ ls /home
aniket   rahul   john

$ ls /home/aniket
Desktop   Documents   Downloads   Pictures   .bashrc

Here, each user has a separate workspace under /home, keeping their files and settings isolated from others.


/bin – User Binaries

  • The /bin directory contains essential binary executables (programs) that are required for the system to function, especially in single-user mode (recovery or minimal mode).
  • These are the basic commands needed for both the system and all users.
  • Commands in /bin are available to all users (not just root).
  • Common everyday commands like ls, cp, mv, cat, mkdir, etc., are stored here.
  • Since these are critical system commands, the /bin directory is always mounted and available.

Example:

$ ls /bin | head
bash
cat
cp
ls
mkdir
mv
rm
sh
echo
pwd

Here, you can see some of the essential commands stored in /bin that are available system-wide.


/sbin – System Binaries

  • The /sbin directory contains system administration binaries (programs).
  • It is similar to /bin, but the commands here are primarily intended for the system administrator (root user).
  • These binaries are essential for system maintenance, configuration, and troubleshooting.
  • Normal users usually don’t need to access them, and in many cases, running them requires sudo.
  • Examples of commands found in /sbin: iptables, reboot, fdisk, ifconfig.

Example:

$ ls /sbin | head
reboot
shutdown
ifconfig
fdisk
iptables
mount
umount
fsck
swapoff
swapon

Here, /sbin contains administrative tools needed for managing the system, unlike /bin which holds everyday user commands.


/dev – Device Files

  • The /dev directory contains special device files that represent hardware and virtual devices on your system.
  • In Linux, everything is treated as a file, including hardware. This allows programs and the operating system to interact with devices by reading from or writing to these files.
  • Hardware devices like hard disks, USB drives, and terminals are represented here.
  • Virtual devices like /dev/null or /dev/zero are also found here.
  • System processes and administrators use these files to interact with devices.
  • /dev is a core directory in Linux, because without it the OS couldn’t communicate with disks, input devices, or terminals.

Example:

$ ls /dev | head
null
zero
tty
sda
sda1
sdb
sdb1
random
urandom
loop0

Here:

  • sda, sdb, etc. → Represent hard disks/partitions.
  • tty → Refers to terminals.
  • null, zero, random → Virtual devices used by programs.

/var – Variable Files

  • The /var directory stores variable data files that are expected to change frequently as the system runs.
  • Unlike /etc (which holds static configuration files), /var contains files that grow over time such as logs, caches, and temporary data.
  • It is essential for system logging, package management, mail, and temporary runtime files.
  • Since these files can grow large, the /var directory is often monitored to prevent running out of disk space.

Common Subdirectories in /var:

  • /var/log → System and application log files (e.g., syslog, auth.log)
  • /var/lib → Variable state information, including databases and package manager files
  • /var/mail → User email inboxes (if mail services are configured)
  • /var/tmp → Temporary files that need to persist between reboots

Example:

$ ls /var | head
backups
cache
lib
local
lock
log
mail
opt
run
tmp

Here:

  • /var/log → Holds system log files.
  • /var/lib → Stores package manager and database data.
  • /var/tmp → Used for temporary files that survive reboots.

/boot – Boot Loader Files

The /boot directory contains the essential files required to boot the Linux system.
This includes the Linux kernel, the initial RAM disk image, and the boot loader (such as GRUB).

Common contents in /boot:

  • Kernel images → e.g., vmlinuz-5.15.0-92-generic
  • Initial RAM disk → e.g., initrd.img-5.15.0-92-generic
  • GRUB files → Boot loader configuration and stages
  • System map files → Kernel symbol table used for debugging

Example:

$ ls /boot
config-5.15.0-92-generic
grub
initrd.img-5.15.0-92-generic
System.map-5.15.0-92-generic
vmlinuz-5.15.0-92-generic

Here:

  • vmlinuz → The compressed Linux kernel.
  • initrd.img → The initial RAM disk loaded before the kernel.
  • grub/ → Contains bootloader configuration files.
  • System.map → Provides a symbol table for debugging the kernel.

/tmp – Temporary Files

The /tmp directory is used to store temporary files created by both the system and users.
It acts as a workspace for programs that need a place to write temporary data.

  • Files stored here are usually deleted automatically when the system reboots.
  • Any user can read and write to /tmp, but permissions are restricted so that users cannot access each other’s files.
  • Applications often use /tmp for session data, lock files, or caches.

Example:

$ ls /tmp
snap-private-tmp
systemd-private-xyz
tmpfile123

Here:

  • tmpfile123 → A random temporary file created by an application.
  • systemd-private-*Temporary runtime files created by system services.
  • snap-private-tmpApp-specific temp directory created by snap packages.

/mnt – Mount Directory

The /mnt directory is traditionally used for temporarily mounting filesystems.
System administrators often use it as a convenient place to attach additional storage such as external drives, ISO images, or network filesystems.

  • By default, it’s an empty directory.
  • Temporary filesystems or partitions can be mounted here for quick access.
  • Modern Linux systems also use /media for removable media like USB drives, but /mnt is still widely used for manual or temporary mounts.
  • In short: /mnt = a staging area for temporary mounts.

Example:

$ sudo mount /dev/sdb1 /mnt
$ ls /mnt
project-data  backups

Here:

  • /dev/sdb1 → A disk partition manually mounted to /mnt.
  • project-data, backupsFiles and directories accessible from that mounted partition.

/media – Removable Media Devices

The /media directory is used by Linux to automatically mount removable media devices such as USB drives, CDs/DVDs, and external hard drives.

  • When you plug in a removable device, the system typically creates a subdirectory inside /media (often named after the device or the user) and mounts the device there.
  • Unlike /mnt, which is meant for manual temporary mounts, /media is managed by the system for plug-and-play devices.
  • Each device gets its own subdirectory for easy access.

Example:

$ ls /media
aniket

$ ls /media/aniket
USB_DRIVE  EXT_DISK

Here:

  • /media/aniket/USB_DRIVE → A USB drive automatically mounted by the system.
  • /media/aniket/EXT_DISK → An external hard disk mounted for the user.

/usr – User Binaries and Applications

The /usr directory is one of the largest and most important directories in Linux.
It contains user applications, utilities, libraries, and documentation that are not essential for basic system booting but are required for normal multi-user operations.

Think of /usr as the place where most of the user-level programs and software packages live.

Key subdirectories inside /usr:

  • /usr/bin
    → User binaries and common executables (e.g., ls, cp, mv).

  • /usr/sbin
    → System administration binaries (e.g., apache2, sshd).

  • /usr/lib
    → Shared libraries for programs in /usr/bin and /usr/sbin.

  • /usr/local
    → Locally installed software and packages (not managed by the system package manager).

  • /usr/share
    → Architecture-independent data, like documentation, icons, and localization files.

Example:

$ ls /usr | head
bin
sbin
lib
local
share
games
include
src

Here:

  • /usr/bin → Contains most of the user commands available to all users.
  • /usr/sbin → Holds system administration tools.
  • /usr/lib → Provides the shared libraries required by binaries.
  • /usr/local → Where aniket can install custom software without affecting system files.
  • /usr/share → Stores common resources like man pages, documentation, and icons.

/etc – Configuration Files

The /etc directory contains all the system configuration files.
It is one of the most critical directories in Linux, as it controls the behavior of the operating system and installed applications.

  • Configuration files in /etc define how the system starts, runs, and shuts down.
  • It also includes startup and shutdown scripts that control services and programs.
  • Many application-specific configuration files are stored here (e.g., web servers, databases, networking).

Without /etc, a Linux system cannot function properly.

Common files and subdirectories in /etc:

  • /etc/passwd → User account information.
  • /etc/shadow → Secure user password data.
  • /etc/hostname → System hostname.
  • /etc/hosts → Static table for hostnames and IP mappings.
  • /etc/fstab → Filesystem mount information.
  • /etc/network → Network configuration files.
  • /etc/init.d/ → Service startup scripts.

Example:

$ ls /etc | head
passwd
shadow
hostname
hosts
fstab
network
init.d
ssh
cron.d
resolv.conf

Here:

  • /etc/passwd → Stores user account details.
  • /etc/shadow → Holds encrypted passwords (accessible only by root).
  • /etc/hostname → Defines the system’s hostname (e.g., aniket-PC).
  • /etc/hosts → Maps hostnames to IP addresses.
  • /etc/fstab → Defines disks and partitions to mount at boot.
  • /etc/network → Contains network interface settings.
  • /etc/init.d/ → Holds service management scripts.

/opt – Optional Applications

The /opt directory is meant for optional or third-party applications.
Think of it as a place where software from outside your Linux distribution usually gets installed.

  • If you install software from a vendor (not through your package manager like apt or yum), chances are it will land in /opt.
  • The program’s files and libraries live inside /opt, while links to the actual executables are often placed in /bin so that all users can run them easily.
  • It’s a clean way to keep vendor software separate from the rest of the system.

Example:

$ ls /opt
google
vmware

Here:

  • /opt/google/ → Contains files for Google applications (e.g., Chrome).
  • /opt/vmware/ → Contains files for VMware software.

/lib – Essential Shared Libraries

The /lib directory contains shared libraries (similar to DLL files in Windows) that are needed for the system to run.
These libraries provide essential code that programs and the kernel depend on.

  • Programs in /bin and /sbin use the libraries stored here.
  • Without /lib, most of the basic Linux commands wouldn’t even start.
  • It also contains kernel modules that help Linux communicate with hardware.

Common subdirectories:

  • /lib/modules/ → Kernel modules (drivers).
  • /lib64/ → 64-bit libraries (on 64-bit systems).

Example:

$ ls /lib | head
modules
systemd
terminfo
udev
x86_64-linux-gnu
firmware
libc.so.6
ld-linux-x86-64.so.2

Here:

  • /lib/modules/ → Stores kernel modules (device drivers).
  • /lib64/ → Contains 64-bit libraries on a 64-bit system.
  • libc.so.6 → The C standard library, required by most programs.
  • ld-linux-x86-64.so.2 → The dynamic linker/loader that loads shared libraries for programs.

/srv – Service Data

The /srv directory is used to store data for services provided by the system.
Think of it as the place where a server keeps its files that are directly shared with users.

  • If your Linux machine is running a web server, the website files might live in /srv/www/.
  • If it’s running an FTP server, the files could be in /srv/ftp/.
  • Basically, /srv holds the “served” data — the content that your system delivers to the outside world.

Examples:

  • /srv/www/ → Website files for a web server.
  • /srv/ftp/ → Files for an FTP server.

This directory is usually empty on desktops but becomes important on server systems.


/proc – Process Information

The /proc directory is a virtual filesystem that provides information about the system and running processes.
It doesn’t contain “real” files stored on disk — instead, the files here are generated by the kernel on the fly.

  • Each running process gets its own directory under /proc named by its process ID (PID).
    For example, /proc/1234/ would contain details about the process with PID 1234.
  • You can also find system information such as CPU, memory, and kernel details here.

    Common files in /proc:

  • /proc/cpuinfo → Information about the CPU.
  • /proc/meminfo → Memory usage details.
  • /proc/uptime → How long the system has been running.
  • /proc/[PID]/ → Information about a specific process.

In short: /proc is like a window into the brain of the Linux kernel, letting you peek at what’s happening inside your system in real time.


Conclusion

Linux may seem tricky at first, but every folder has a purpose.
Once you get used to them, using the system becomes much easier.

With a little practice, these directories will feel familiar.

0
Subscribe to my newsletter

Read articles from Aniket Raje directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aniket Raje
Aniket Raje