How does the `du' utility work?

How does the `du' utility work?


du simply traverses the directory structure calling stat()
(or more accurately, lstat()) on every file and directory it
encounters, adding up the number of blocks consumed by each.



If you want more detail about how it works, then the simple answer is:





Use the source, Luke!




Source for BSD systems (FreeBSD, NetBSD and OpenBSD) is available as
unpacked source trees on their FTP distribution sites; source for GNU
versions of utilities is available from any of the GNU mirrors, but you
have to unpack the archives yourself.






Home FAQ