A file system is the method and data structure that an OS uses to control how data is stored and retrieved on storage devices. Without a file system, data on disk would be one large unstructured blob.
- Organizing data into files and directories
- Tracking free/used disk space
- Managing file metadata (name, size, timestamps, permissions)
- Providing access control
- Supporting operations: create, read, write, delete, rename
| File System | OS | Max File Size | Max Volume | Features |
|---|---|---|---|---|
| ext4 | Linux | 16 TB | 1 EB | Journaling, widely used |
| btrfs | Linux | 16 EB | 16 EB | Snapshots, RAID, CoW |
| xfs | Linux | 8 EB | 8 EB | High performance, large files |
| zfs | Linux/FreeBSD | 16 EB | 256 ZB | Pooled storage, checksums |
| NTFS | Windows | 16 TB | 256 TB | ACLs, encryption, journaling |
| FAT32 | Universal | 4 GB | 8 TB | Legacy, USB drives |
| exFAT | Universal | 128 PB | 128 PB | Modern USB/SD cards |
| APFS | macOS | 8 EB | 8 EB | Encryption, snapshots |
The Filesystem Hierarchy Standard (FHS) defines the directory structure for Linux.
/ β Root (everything lives here)
βββ bin/ β Essential user binaries (ls, cp, bash)
βββ sbin/ β System binaries (for root: fdisk, iptables)
βββ boot/ β Bootloader files, kernel images
βββ dev/ β Device files (sda, tty, null, random)
βββ etc/ β System-wide configuration files
β βββ passwd β User account info
β βββ shadow β Hashed passwords
β βββ hosts β Static hostname/IP map
β βββ fstab β Filesystem mount table
β βββ ssh/ β SSH daemon configuration
β βββ systemd/ β Systemd unit files
βββ home/ β User home directories
β βββ alice/ β Alice's files
β βββ bob/ β Bob's files
βββ lib/ β Shared libraries for /bin and /sbin
βββ lib64/ β 64-bit shared libraries
βββ media/ β Mount points for removable media
βββ mnt/ β Temporary mount points
βββ opt/ β Optional/third-party software
βββ proc/ β Virtual FS β kernel/process info
β βββ cpuinfo β CPU details
β βββ meminfo β Memory details
β βββ [PID]/ β Per-process info
βββ root/ β Root user's home directory
βββ run/ β Runtime data (PIDs, sockets)
βββ srv/ β Data served by the system (web, FTP)
βββ sys/ β Virtual FS β hardware/kernel info
βββ tmp/ β Temporary files (cleared on reboot)
βββ usr/ β User utilities and applications
β βββ bin/ β Most user commands (git, python, vim)
β βββ lib/ β Libraries for /usr/bin
β βββ local/ β Locally compiled software
β βββ share/ β Architecture-independent data
βββ var/ β Variable data (logs, spools, caches)
βββ log/ β System logs
βββ www/ β Web server files
βββ cache/ β Application cache data
βββ run/ β Runtime variable data
| Directory | Purpose | Example Contents |
|---|---|---|
/etc |
System configuration | /etc/nginx/nginx.conf, /etc/hosts |
/var/log |
Log files | /var/log/syslog, /var/log/auth.log |
/proc |
Virtual: process/kernel info | /proc/cpuinfo, /proc/1234/maps |
/sys |
Virtual: hardware/driver info | /sys/class/net/eth0/ |
/dev |
Device files | /dev/sda, /dev/null, /dev/tty |
/tmp |
Temporary files | Cleared on boot |
/home |
User data | /home/username/ |
/root |
Root user home | /root/.ssh/authorized_keys |
Windows uses drive letters as roots (C:, D:, etc.), unlike Linux's unified /.
C:\ β System drive (primary)
βββ Windows\ β OS files
β βββ System32\ β Core system DLLs and executables
β βββ SysWOW64\ β 32-bit compat on 64-bit
β βββ drivers\ β Device drivers (.sys files)
β βββ Temp\ β System temp files
βββ Program Files\ β 64-bit installed applications
βββ Program Files (x86)\ β 32-bit installed applications
βββ Users\ β User profiles
β βββ Username\
β β βββ Desktop\
β β βββ Documents\
β β βββ Downloads\
β β βββ AppData\
β β β βββ Local\ β Local app data
β β β βββ LocalLow\ β Low-integrity app data
β β β βββ Roaming\ β Syncs with domain profile
β β βββ .ssh\ β SSH keys
β βββ Public\ β Shared between all users
βββ ProgramData\ β Machine-wide app data (hidden)
βββ Temp\ β System temp (also %TEMP%)
| Path | Variable | Purpose |
|---|---|---|
C:\Users\%USERNAME% |
%USERPROFILE% |
Current user's home |
C:\Windows\System32 |
%WINDIR%\System32 |
System executables |
C:\Users\%USERNAME%\AppData\Roaming |
%APPDATA% |
App config (roaming) |
C:\Users\%USERNAME%\AppData\Local |
%LOCALAPPDATA% |
App data (local) |
C:\ProgramData |
%PROGRAMDATA% |
Machine-wide app data |
C:\Windows\Temp |
%TEMP% |
Temp files |
Absolute: /home/alice/documents/report.pdf
β starts from root /
Relative: documents/report.pdf
β relative to current directory
Special:
. = current directory
.. = parent directory
~ = home directory (/home/username)
~alice = alice's home directory
Absolute: C:\Users\Alice\Documents\report.pdf
β starts from drive letter
Relative: Documents\report.pdf
β relative to current directory
Special:
. = current directory
.. = parent directory
%USERPROFILE% = home directory
graph TD
ROOT["/"]
ROOT --> HOME["/home"]
ROOT --> ETC["/etc"]
ROOT --> VAR["/var"]
HOME --> ALICE["/home/alice"]
HOME --> BOB["/home/bob"]
ALICE --> DOCS["/home/alice/docs"]
ALICE --> PROJ["/home/alice/projects"]
CWD["π CWD = /home/alice"]
CWD -->|"cd .."| HOME
CWD -->|"cd docs"| DOCS
CWD -->|"cd /etc"| ETC
CWD -->|"cd ~bob"| BOB
Linux represents everything as a file. The ls -l output shows the file type as the first character:
-rw-r--r-- 1 alice staff 1024 Apr 22 10:00 file.txt
drwxr-xr-x 2 alice staff 4096 Apr 22 10:00 directory/
lrwxrwxrwx 1 alice staff 10 Apr 22 10:00 link -> /etc/hosts
crw-rw-rw- 1 root tty 5 Apr 22 10:00 /dev/tty
brw-rw---- 1 root disk 8,0 Apr 22 10:00 /dev/sda
prw-r--r-- 1 alice staff 0 Apr 22 10:00 mypipe
srwxrwxrwx 1 alice staff 0 Apr 22 10:00 mysocket
| First Char | Type | Description |
|---|---|---|
- |
Regular file | Text, binary, data |
d |
Directory | Container for files |
l |
Symbolic link | Pointer to another file |
c |
Character device | Serial, TTY (/dev/tty) |
b |
Block device | Disks (/dev/sda) |
p |
Named pipe (FIFO) | IPC between processes |
s |
Socket | Network/IPC socket |
An inode (index node) stores file metadata β everything except the filename and actual data.
Directory Entry Inode #1042 Data Blocks
βββββββββββββββββ ββββββββββββββββββ ββββββββββββββββ
β "report.txt" ββββββββΆβ inode: 1042 ββββββββΆβ "Hello World"β
β inode: 1042 β β size: 12 bytes β β ...file data β
βββββββββββββββββ β owner: alice β ββββββββββββββββ
β perms: 644 β
β atime: ... β
β mtime: ... β
β ctime: ... β
β links: 1 β
ββββββββββββββββββ
atimeβ Last access timemtimeβ Last modification time (content)ctimeβ Last change time (metadata or content)
stat report.txt # Show inode info
ls -i # Show inode numbers
df -i # Show inode usage per filesystemHard Link:
file.txt βββ
ββββΆ inode 1042 βββΆ Data Blocks
hardlink βββ
(same inode, both point to same data)
Symbolic Link:
symlink.txt βββΆ "file.txt" (path string) βββΆ inode 1042 βββΆ Data
(separate inode, stores path as data)
| Feature | Hard Link | Symbolic Link |
|---|---|---|
| Inode | Same as original | Different |
| Cross-filesystem | β No | β Yes |
| Works on directories | β No (usually) | β Yes |
| Broken if original deleted | β No (data survives) | β Yes (dangling link) |
| Command | ln file hardlink |
ln -s target link |
In Linux, storage devices are mounted to directories (mount points).
# View current mounts
mount
df -h # Disk usage with human-readable sizes
lsblk # Block device tree
# Mount a device
sudo mount /dev/sdb1 /mnt/usb
# Unmount
sudo umount /mnt/usb
# Auto-mount at boot (edit /etc/fstab)
# Device Mount Point FS Type Options Dump Pass
/dev/sda1 / ext4 defaults 0 1
/dev/sda2 /home ext4 defaults 0 2
UUID=xxxx /mnt/data btrfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 0Detailed coverage in 05_Permissions.md
-rwxr-xr-- alice staff file.sh
βββββββββ
βββββ€ββββ€βββββ others: r-- (read only)
β β ββββββ group: r-x (read + execute)
β βββββββββββ owner: rwx (full)
βββββββββββββββ file type: - (regular)
- Linux CLI Basics β
- Windows CLI Basics β
- User Permissions β
- File Management β
- System Monitoring & Logging β