To find the Linux size of a directory, use du -sh dirname for a human-readable total, or du -h --max-depth=1 dirname to compare subfolders. Confirm disk free space with df -h. Success means you know which trees consume space before you delete or remove directories.
Shortest path: du -sh ~/Downloads. Rank children: du -h --max-depth=1 ~/Downloads | sort -h.

To locate files before you create, copy, move, or delete them, see how to find files in Linux.
Quick Totals with du
du -sh /path/to/dir
du -sh *
du -ah /path/to/dir | sort -h | tail
du estimates file space usage. -s summarizes; -h prints human units (K/M/G). Without -s, du lists every subdirectory—useful but noisy on large trees.
Compare Subdirectories
du -h --max-depth=1 /var | sort -h
# some systems use -d 1 instead of --max-depth=1
This view answers “which folder ate my disk?” better than a single total. Delete or archive the offenders deliberately after backups.
du vs df vs ls
- du: space used by files under a path
- df: free/used space on mounted filesystems
- ls -l: apparent file sizes, not recursive directory totals
df -h .
du -sh .
ls -l
Ask Ubuntu discussions often clarify discrepancies: sparse files, open deleted files, and different block sizes can make tools disagree slightly. For cleanup decisions, du on the directory plus df on the mount is enough.
Apparent Size vs Disk Usage
Some du versions support --apparent-size to show logical sizes versus allocated blocks. Sparse files look “huge” logically but use little disk. Know which question you are asking: storage capacity planning vs transfer size estimates.
Exclude and Focus
du -sh --exclude=.git project/
du -sh --exclude=node_modules project/
Excludes help when dependency folders dominate. Still measure them once—sometimes node_modules is the entire problem.
Before You Delete
- Identify largest children with depth-limited du.
- Copy or backup keepers.
- Move uncertain trees to quarantine.
- Delete files or remove directories intentionally.
- Re-run
duanddfto confirm recovery.
Performance on Huge Trees
First du on a cold multi-terabyte tree takes time—du must walk inodes. Narrow scope to suspect paths. Avoid running heavy du against network mounts during peak hours without need.
Readable Reports for Teams
du -h --max-depth=2 /var/log | sort -h > /tmp/log-usage.txt
cat /tmp/log-usage.txt
Share the report before proposing deletes. Numbers beat guesses in incident channels.
Verify You Measured the Right Place
pwd
realpath .
du -sh "$(pwd)"
Symlink farms can redirect what you think you are measuring. Prefer absolute paths after realpath.
Scheduled reports help more than one-off panic measurements. A weekly du snapshot of /var and home directories into a dated log makes growth trends obvious before disks hit 100%. Pair with alerts on df thresholds so humans intervene early.
Containers and build caches inflate directories quietly: Docker images, language package caches, browser profiles, and IDE indexes. Measure those known suspects explicitly instead of only staring at the project root. Clearing the wrong cache wastes time; clearing the right one restores gigabytes.
When presenting sizes to non-Linux stakeholders, convert to GB and include the mount’s free space from df -h. “The folder is 40G and the disk has 3G free” is an actionable sentence. Raw block counts are not.
After cleanup, measure again. Confirmation prevents the false belief that deletes worked when you removed a symlink or an empty directory while the heavy data lived elsewhere. Trust the second du, not the hope.
Home directory surprises often hide in ~/.cache, browser profiles, and old virtualenv trees. Measure those explicitly: du -sh ~/.cache /* 2>/dev/null | sort -h | tail. Clean caches with application-native tools when possible so you do not break formats mid-flight.
For capacity planning, track growth rate, not only today’s total. A folder that grew 10G in a week deserves investigation even if the disk is not full yet. du reports become operational intelligence when you keep historical copies in a dated log directory your whole team can read without asking for SSH access first thing Monday morning during standup.
If sort is unavailable in a tiny container, still run plain du -h --max-depth=1 and read carefully. Tooling gaps are not an excuse to skip measurement before deletes. Eyes on numbers first; fingers on rm second. That habit scales from a laptop SSD to a production data disk without changing philosophy.
To get the Linux size of a directory, start with du -sh, break down children with depth limits and sort -h, then use df to confirm filesystem free space before cleanup.
Practice destructive commands only inside a throwaway tree such as ~/tmp-practice. Create sample files with touch, copy them, then delete the copies—not your only originals. Run ls -la before and after every experiment. Ten calm minutes of drills beat one panicked recovery attempt.
Quote paths, prefer -i while learning, and never run recursive deletes against /, ~, or unreviewed globs. Most disasters are one misplaced space or an expanded * away. Slow down on production hosts; go fast only where rebuild is cheap. If a command feels clever, it is probably unsafe without a dry run.
Read rm(1), rmdir(1), and du(1) once. You do not need every flag memorized—you need to know where to look when an error is unfamiliar. Official man pages beat viral “one weird tip” posts that skip warnings and sell false confidence.
On shared machines, announce bulk deletes in chat. Cron jobs and teammates may still expect yesterday’s paths. Prefer moving into an Archive folder for a week before permanent rm when you are unsure. That quarantine habit has saved more teams than any force flag ever will.
Before you delete project folders that hold drafts, export finished DOCX, XLSX, or PDF copies you still need for school or work. Terminal cleanup is permanent on most systems—office-ready exports are your safety net when Trash is not available.
WSL users should delete inside the Linux filesystem for project trees. Cross-deleting under /mnt/c works but follows Windows permissions and can surprise you with locked files. Confirm with pwd before recursive flags. Keep Windows Explorer closed on files you plan to remove from WSL.
Keep a personal checklist: list → measure size if needed → backup or move → delete → verify gone. That order turns risky commands into a boring routine—which is exactly what you want on Friday afternoons and during incidents alike.
Teach juniors the same order out loud before they receive sudo. Narrating pwd, ls, and intended targets catches typos that eyes skip when someone is stressed. Pair programming beats postmortems.
Finally, separate “cleanup” from “secure erase.” Everyday rm/rmdir/du workflows reclaim space and reduce clutter. Classified-data destruction policies require approved wipe procedures beyond this beginner series—follow your organization’s standards when those rules apply.
Cross-link your personal notes to the sibling skills: create, copy, move, and rename. File hygiene is a loop, not a single command. Operators who practice the whole loop make fewer irreversible mistakes when disks fill at inconvenient times.
If you remember only one sentence, make it this: measure and list before you destroy, and verify after. That sentence covers delete file, remove directory, and directory sizing better than any force-flag folklore circulating in chat threads.
After Measuring Disk Use: Share the Size Report
du shows where space went. Managers and teammates usually want that summary as a table or short report—not a wall of terminal numbers.
WPS Office for Linux is ideal for that report: Spreadsheet for directory size tables, Writer for commentary, and PDF when the snapshot should stay fixed.

| What you need next | What WPS gives you |
|---|---|
| Turn du output into a readable size report | Strong .docx / .xlsx / .pptx layout fidelity when files move between Linux, Windows, and macOS |
| One place for notes, sheets, slides, and PDFs | Free core suite: Writer, Spreadsheet, Presentation, plus PDF view/edit/convert tools |
| A familiar desktop UI for switchers | Ribbon-style apps with a lighter footprint than many heavy suites |
| A trusted install path | Official DEB (Ubuntu/Debian/Mint) and RPM packages from the vendor |
Use the official WPS Office for Linux download page, install with sudo apt install ./wps-office_VERSION_amd64.deb, paste the top offenders into a sheet, and share the DOCX/PDF instead of another screenshot of the terminal.
FAQ
Why du and df disagree?
Different scopes, reserved blocks, open deleted files, or mounts. Measure both and interpret in context.
How do I find the largest files?
find /path -type f -printf "%s\t%p\n" 2>/dev/null | sort -n | tail
Does du follow symlinks?
Defaults usually do not follow into other trees; check man flags if results look doubled.
How do I measure remote folders?
Run du on the system that hosts the files, or use tools designed for the protocol—not a naive local assumption.
Can I get live progress?
Standard du is silent until done; narrow the path for faster feedback.
Is ncdu better?
Interactive tools like ncdu help exploration when installed from official repos—still based on the same walk idea.
How often should I check?
After big downloads, before deletes, and when df shows the disk filling.
Does trash still use space?
Yes—empty Trash/GUI wastebaskets separately from shell rm. Measure Trash folders too if your desktop environment stores them under the home directory where they quietly steal gigabytes.
Should I run du as root?
Only when you must read directories your user cannot enter. Prefer least privilege; sudo du on / can be slow and noisy.
Directory sizing is how you aim cleanup. Without du, deletes are guesswork. With du and df together, you know what to archive, what to remove, and whether the filesystem actually recovered space afterward—close the loop every time. Make “du before rm” as automatic as buckling a seatbelt before driving, even on familiar machines you think you already understand completely after years of daily use at work and home on every laptop you touch during busy weeks.




