Printing Disk Usage with du
The du command prints the size of each file and directory that is inside the current directory. Its most basic usage is as easy as it gets:
matthew@seymour:~$ du
That outputs a long list of directories and how much space their files take up. You can modify that with the -a parameter, which instructs du to print the size of individual files as well as directories. Another useful parameter is -h, which makes du use human-readable sizes like 18M (18MB) rather than 17532 (the same number in bytes, unrounded). The final useful basic option is -c, which prints the total size of files.
So, using du we can get a printout of the size of each file in our /home directory, in human-readable format, and with a summary at the end, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access