DEV Community

Cover image for Understanding Linux File Hierarchy — A Beginner-Friendly Guide with Use Cases
AugustineOzor
AugustineOzor

Posted on

Understanding Linux File Hierarchy — A Beginner-Friendly Guide with Use Cases

Table of Contents

Overview

In Linux, everything even devices is treated as a file. The File System Hierarchy (FHS) is a tree-like structure starting at the root (/). Understanding it is key for sysadmins, developers, and DevOps teams.

This article explains the main directories, their roles, and useful commands to navigate them.

What is the Linux File Hierarchy

Linux uses a single-rooted, inverted tree-like file system where all files and directories stem from the root (/).
Image description

Each folder under / serves a specific purpose. Understanding these functions helps streamline system navigation, automation, and troubleshooting.

Core Directories and Their Purpose

Of course! Here's the cleaned-up version of your Linux core directories table without examples:

Directory Purpose
/ Root of the file system; the starting point.
/root Home directory for the root (superuser).
/bin Essential binary commands.
/sbin System administration binaries.
/etc Configuration files for services and applications.
/home User home directories.
/dev Device files.
/var Variable data such as logs and cache.
/proc Runtime system process information.
/usr User-level applications and binaries.
/opt Optional third-party applications.
/mnt Temporary mount point for external file systems.
/media Auto-mounted removable media.

What is Bash?

Bash (Bourne Again SHell) is the default command-line interpreter in most Linux systems. It lets you run commands, scripts, and automate tasks — like a more powerful version of Windows Command Prompt.

Here is the Windows command prompt interface.
Image description

Essential Commands and Functions

pwd Prints current working directory.
Image description

ls Lists files and folders in the current directory.|
Image description

cd Changes directory.
Image description

clear Clears the terminal screen.
Image description
Image description

uname Shows operating system name.
Image description

uname -r Displays kernel version.
Image description

whoami Displays current user.

Image description

date Displays current date and time.
Image description

history Lists command history.

Image description

Business Use Case

Let’s say you're setting up a web server in a cloud environment using AWS or Azure. You'll likely:

Store config files in /etc/nginx/

Image description

Serve web pages from /var/www/html

Image description

Monitor logs in /var/log/nginx/access.log

Image description

Install optional tools in /opt

Image description

For Security Teams
Understanding /proc, /dev, and /var/log is critical for:

  • Monitoring running processes
  • Identifying hardware vulnerabilities
  • Reviewing audit and access logs

dev

Image description

proc

Image description

/usr

Image description

sbin

Image description

bin
Image description

media

Image description

Benefits of Understanding File Hierarchy

  • Efficient Navigation: Jump between directories without guesswork
  • Troubleshooting: Easily locate logs and configurations
  • Automation: Write cleaner Bash scripts with proper pathing
  • Security: Manage user access based on directory structures
  • Compliance: Ensure data, logs, and access controls follow best practices

Learning Linux File Hierarchy is like learning the layout of a building before doing maintenance. You’ll be faster, more efficient, and more confident in managing systems.

Top comments (0)