Terminal Tips: Summarizing Folder Disk Usage on Linux & Mac

Terminal Tips: Summarizing Folder Disk Usage on Linux & Mac

The command du -sh * is used in Unix-like operating systems (such as Linux and macOS) to display the disk usage of files and directories in the current directory.

Here's a breakdown of what each part of the command does:

  • du: Stands for "disk usage". This command estimates and displays the amount of disk space used by files and directories.

  • -s: Stands for "summarize". This option du displays only the total size of each argument (file or directory) instead of the size of each file within directories.

  • -h: Stands for "human-readable". This option makes the output more readable by converting the sizes into a human-readable format, using units like kilobytes (K), megabytes (M), gigabytes (G), etc.

  • *: This is a wildcard that matches all files and directories in the current directory.

When you run du -sh *, the command will output the total disk usage for each file and directory in the current directory, in a human-readable format. Here's an example output: