Linux Commands Helper
💬 Your AI-powered Linux assistant
du Command - Estimate File and Directory Space Usage
The du command is used to estimate and summarize disk space used by files and directories. It is useful for finding out which directories are using the most space.
Syntax
du [options] [file...]
Examples
du -sh *
Show the total size of each item in the current directory in human-readable format.
du -ah /var
Display the size of all files and directories under /var in human-readable format.
du -csh /home/*
Show the total size of all directories in /home and a grand total.
Notes
- Use the
-h
option for human-readable output (e.g., MB, GB). - Combining
du
withsort
helps find the largest directories:du -sh * | sort -hr
. - Some filesystems or mount points may require root privileges to access all data.