Skip to main content

Command Palette

Search for a command to run...

Linux File System Hierarchy (FHS)

The Linux file system is organized as a tree structure starting from the root directory (/).

Updated
2 min read
Linux File System Hierarchy (FHS)

Important Directories

Directory Purpose
/ Root directory, top of the filesystem
/bin Essential user commands (ls, cp, mv, cat)
/sbin System administration commands
/etc Configuration files
/home User home directories
/root Root user's home directory
/var Logs and frequently changing data
/tmp Temporary files
/usr User applications and utilities
/boot Bootloader and kernel files
/dev Device files
/proc Process and kernel information
/sys System hardware information
/opt Optional third-party software
/mnt Temporary mount points
/media USB drives and removable media

Real-World Troubleshooting Scenario

Scenario: Disk Space Suddenly Full

User Complaint

Website is slow and application logs are not being generated.


Investigation

Step 1: Check Disk Usage

df -h

Output

Filesystem      Size  Used Avail Use%
/dev/xvda1       20G   20G    0G 100%

Step 2: Find Large Directories

du -sh /* 2>/dev/null

Output:

12G /var
2G  /usr
1G  /home

/var is consuming most space.


Step 3: Inspect Log Directory

cd /var/log
du -sh *

Output:

10G nginx

Nginx logs are filling the disk.


Fix

Compress or remove old logs:

sudo rm old-access.log
sudo rm old-error.log

Or rotate logs:

sudo logrotate -f /etc/logrotate.conf

Verify

df -h

Output:

Filesystem      Size  Used Avail Use%
/dev/xvda1       20G   10G   10G 50%

Disk space recovered.


Commands Practiced

pwd
ls
cd
df -h
du -sh
find

What I Learned Today

✅ Linux starts from the root directory (/)

✅ Every directory has a specific purpose

✅ Logs are usually stored in /var/log

✅ Configuration files are stored in /etc

✅ User data is stored in /home

✅ Disk-space issues can often be traced using:

  • df -h

  • du -sh

  • find

32 views