|$ curl https://forge-ai.dev/api/markdown?path=docs/linux/filesystem
$cat docs/linux-file-system.md
updated Recently·22 min read·published

Linux File System

LinuxFilesystemStorageBeginner to Intermediate🎯Free Tools
Introduction

Everything in Linux is a file: documents, directories, devices, sockets, and pipes. Understanding how the file system is organized and how to inspect it is essential for debugging, deployment, and automation.

Filesystem Hierarchy Standard
PathPurpose
/binEssential command binaries for all users
/sbinEssential system administration binaries
/etcSystem-wide configuration files
/homePersonal directories for users
/rootHome directory for root user
/varVariable data: logs, caches, spool
/tmpTemporary files, often cleared on reboot
/usrUser utilities, libraries, documentation
/optOptional add-on software
/mntTemporary mount points
/mediaRemovable media mount points
Absolute vs Relative Paths
paths.sh
Bash
1# Absolute path — starts from root
2cd /home/alice/projects/webapp
3
4# Relative path — starts from current directory
5cd src/components
6cd ../assets
7cd ./styles
8
9# Special directories
10. # current directory
11.. # parent directory
12~ # current user's home directory
13~bob # user bob's home directory
Disk Usage
disk.sh
Bash
1# Free disk space by filesystem
2df -h
3
4# Directory sizes
5du -sh /var/log
6du -sh * | sort -h # sort directories by size
7
8# Find large files
9find . -type f -size +100M
10
11# Disk usage tree view
12ncdu /var/log
Mounts
mounts.sh
Bash
1# List mounted filesystems
2mount
3findmnt
4
5# Mount a device
6sudo mount /dev/sdb1 /mnt/backup
7
8# Unmount
9sudo umount /mnt/backup
10
11# Persist mounts in /etc/fstab
12# /dev/sdb1 /mnt/backup ext4 defaults,noatime 0 2