Fork me on GitHub

Project Notes

disk usage

How to survey disk usage on linux systems.

Notes

Using du to get folder sizes on Linux-like systems (including macOS).

Summary of a Specific Folder

The s option summarizes the content of a named folder:

$ sudo du -sh /sbin
1.2M /sbin

Or for all sub-directories:

$ sudo du -sh /sbin/*
  0B /sbin/apfs_hfs_convert
 16K /sbin/autodiskmount
 16K /sbin/disklabel
8.0K /sbin/dmesg
8.0K /sbin/dynamic_pager
156K /sbin/emond
 20K /sbin/fibreconfig
 12K /sbin/fsck
  0B /sbin/fsck_apfs
136K /sbin/fsck_cs

Sorting the Results

The output of du is quite suitable for piping via sort and head to get a top 5 (for example):

$ sudo du -sh /sbin/*  | sort -rh | head -5
200K /sbin/launchd
156K /sbin/emond
136K /sbin/pfctl
136K /sbin/fsck_cs
 52K /sbin/nfsd

Credits and References

About LCK#239 bash
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.