du Linux Command
Estimates file and directory space usage (disk usage).
What does du do?
Estimates file and directory space usage (disk usage).
Syntax
du [options] [path]Practical example
du -sh /home/kali/*Questions about du
How do I check directory size with du?
Use `du -sh directory/` to see the total size of a directory. The `-s` summarizes, `-h` makes it human-readable.
How do I see disk usage of all subdirectories?
Use `du -h /path/` to see the size of each subdirectory. Use `du -h --max-depth=1 /path/` to limit depth.
How do I find the largest directories?
Use `du -h --max-depth=1 / | sort -hr | head -10` to find the 10 largest directories at the root level.
How do I see disk usage of files only?
Use `du -sh /path/*` to see sizes of items in a directory. Use `find /path -type f -exec du -sh {} +` for all files recursively.
How do I exclude certain files from du?
Use `du -sh --exclude='*.log' /path/` to exclude files matching a pattern from the disk usage calculation.
How do I see disk usage in megabytes?
Use `du -sm directory/` to display sizes in megabytes. Use `-h` for auto-scaling to the appropriate unit.
How do I see total disk usage of a directory?
Use `du -sh /path/` which summarizes the total size including all subdirectories and files.
How do I see disk usage of current directory?
Use `du -sh .` to see the total size of the current directory and all its contents.
Related Disk Commands
dfReports disk space usage for all mounted filesystems (human-readable with -h).
fdiskManipulates disk partition table (create, delete, resize partitions).
ncduInteractive disk usage analyzer with a terminal UI (ncurses-based).
mountMounts a filesystem (attaches a device to the directory tree).
partedDisk partitioning tool (supports GPT and MBR partition tables).
umountUnmounts a filesystem (detaches a mounted device from the directory tree).