Sobes.tech
Junior — Middle

How does the 'du' command display disk space usage?

sobes.tech AI

Answer from AI

The du (disk usage) command in Unix-like systems displays disk space usage, showing the size of files and directories. By default, it sums the size of all files within the specified directory and outputs the total size in blocks (usually 512 bytes or kilobytes, depending on options).

Example of usage:

du -h /path/to/directory

The -h option displays sizes in a human-readable format (KB, MB, GB).

The command recursively traverses all nested folders, summing the sizes of files, and outputs the total for each directory. Thus, du shows the actual disk space occupied, considering file sizes and directory structure.

How does the 'du' command display disk space usage… - sobes.tech