The terminal’s command line is a simple way to get a disk usage summary in Linux or macOS. Specifically, the “du
” command is the conventional choice but gives much information by default.
Here is the exact syntax for “du
” to return just the summary disk usage value in the directory <somedir>
:
du -chs <somedir>
An example using the “du
” comment for the current directory, where <somedir>
is replaced with a period:
du -chs .
Command Options
du -chs <somedir> -c, --total (produce a grand total) -h, --human-readable (print sizes in human readable format (e.g., 1K 234M 2G)) -s, --summarize (display only a total for each argument)
The key option here is “summarize”, providing just the disk total usage for each argument.