Linux
Disk Usage
Inspect filesystems, large directories, and inodes.
By EZ4Code Team
diskdudf
Code
# Filesystem usage
df -h
df -hT
df -i # inode usage
# Directory sizes (human-readable, summarized)
du -sh /var/*
du -h --max-depth=1 /var | sort -h | tail -20
# Largest files
find / -type f -size +500M -exec ls -lh {} + 2>/dev/null
# Inodes per directory (find inode-hogging dirs)
for d in /*; do echo "$(find "$d" -xdev | wc -l) $d"; done | sort -n | tail
# Mount and unmount
mount /dev/sdb1 /mnt/data
umount /mnt/data
# LVM quick check
lvs && vgs && pvsExplanation
df shows filesystem capacity and free space, while du walks directories to find size hogs. The sort -h pipe ranks directories by size, making cleanup quick. Inode exhaustion, not bytes, can also cause 'no space left on device', so check df -i when disks look empty but writes fail.
More Linux Snippets
File Operations
Copy, move, link, and search files efficiently.
Permissions & Ownership
Manage read/write/execute bits with chmod and chown.
Process Management
List, signal, and monitor running processes.
Networking
Inspect interfaces, ports, connections, and DNS.
Package Management
Install, update, and search packages on Debian and RHEL.
Text Processing
Filter, transform, and summarize text streams.