Operations 5 min read

Master Linux Disk Usage: Essential Commands to Monitor and Manage Filesystems

This guide compiles practical Linux one‑liners for sorting directories by size, listing subdirectories, monitoring disk usage changes, removing unwanted .svn folders, checking inode and partition statistics, and measuring read/write performance, providing sysadmins with quick, actionable tools.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Disk Usage: Essential Commands to Monitor and Manage Filesystems

The article presents a collection of concise Linux command‑line snippets useful for inspecting, sorting, and monitoring disk usage and filesystem information.

Sort directories or files by size and display the top 15 entries: du -xB M --max-depth=2 /var | sort -rn | head -n 15 List the size of all immediate subdirectories: du -h --max-depth=1 Show the ten largest files or directories in the current location: du -s * | sort -n | tail Sort directories by size in descending order with human‑readable units:

du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf "%.1f%s", $1>=2**30?($1/2**30,"G"):$1>=2**20?($1/2**20,"M"):$1>=2**10?($1/2**10,"K"):( $1, "")}e'

Display a sorted file tree for a specific path: du -h /path | sort -h Monitor size changes of a directory every 60 seconds: watch -n60 du /var/log/messages Recursively delete all .svn directories under the current directory: find . -type d -name '.svn' -print0 | xargs -0 rm -rdf Show overall disk usage in a column‑aligned format: df -P | column -t Continuously monitor disk usage every 5 seconds: watch -d -n 5 df Display inode usage for a specific partition: df -i <partition> Sort disks by usage percentage (high to low):

df -h | grep -v ^none | (read header; echo "$header"; sort -rn -k 5)

Show physical disk usage while excluding temporary filesystems and common virtual mounts: df -x tmpfs | grep -vE "(gvfs|procbususb|rootfs)" Display total size and usage of all disks in human‑readable format: df -H List all partitions on a device: fdisk -l /dev/sda Show sector counts instead of cylinder numbers: fdisk -u Display block count for a specific partition: fdisk -s partition Check read/write throughput of a disk: iostat -m -d /dev/sda1 Test raw read speed of a disk: hdparm -t /dev/sda Find all hard links pointing to a given file: find -L / -samefile /path/to/file -exec ls -ld {} + List the five largest files in the current directory tree: find . -type f -exec ls -s {} \; | sort -n -r | head -5 Delete files older than 365 days: find ./ -type f -mtime +365 -exec rm -f {} \; Find files larger than 100 MiB:

find . -type f -size +100M
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

monitoringcommand-lineFilesystemdisk usage
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.