du
The command that adds up how much disk space a directory and everything below it uses.
In more detail
du -sh dir gives one readable total. Where df asks how full the disk is, du asks what is filling it.
Examples
du -sh datadu -sh /var/* ranks the directories under /var. It walks names, so it cannot see deleted files still held open, and if df and du disagree, look for those next. Add -x to stay on one filesystem.log=8G cache=2G next=handles ranks directories, then checks open handles if totals disagree.Related terms
- df — The command that reports total, used and free space for each mounted filesystem.
- filesystem — The way an operating system organises files and folders on a disk or in memory.
- deleted but open file — A file whose last name has been removed but whose data still uses disk space because a process keeps it open.
- block exhaustion — A filesystem running out of free data blocks, so it cannot store more bytes even though it may have inodes left.
Taught in
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- Running Out Of Space: df, du And Inodes — Linux Fundamentals & Systems Administration
- No Space Left, Says The Disk With Room To Spare: Inodes, Held Files, Corruption And Repair — CompTIA Linux+ (XK0-006) Exam Prep
- File Systems: Create, Label, Mount And Repair — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Disk Full At Three In The Morning — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- File System Integrity: Measure, Check, Repair — LPIC-1 Linux Administrator (101-500 and 102-500) Exam Prep