du

Last modified: 
Wednesday, December 16th, 2015

Overview

Notes on using the linux du utility.

Get the size of the current directory with label for the total

du -ch | grep total
2.5G        total

Get the size of the current directory only

du -s

Example

du -s
30248   .

Make file size human friendly

du -sh

Example

du -sh
30M .

List all directories in the current directory (non-recursive)

du -sh *

Example

du -sh *
16K config.yaml
200K    files
30M puppet
116K    shell

By default du listings are recursive and redundant

du
28  ./shell/ascii-art
116 ./shell
12  ./files/exec-once
12  ./files/exec-always
12  ./files/startup-once
12  ./files/startup-always
88  ./files/dot/ssh
148 ./files/dot
200 ./files
344 ./puppet/nodes
16  ./puppet/modules/postgresql/templates
28  ./puppet/modules/postgresql/lib/puppet/type
40  ./puppet/modules/postgresql/lib/puppet/parser/functions
44  ./puppet/modules/postgresql/lib/puppet/parser
16  ./puppet/modules/postgresql/lib/puppet/provider/postgresql_conf
16  ./puppet/modules/postgresql/lib/puppet/provider/postgresql_psql
36  ./puppet/modules/postgresql/lib/puppet/provider
112 ./puppet/modules/postgresql/lib/puppet
116 ./puppet/modules/postgresql/lib
[*snipped lots of directories here*]
16  ./puppet/modules/puphpet/files
120 ./puppet/modules/puphpet/manifests/php
16  ./puppet/modules/puphpet/manifests/mysql
16  ./puppet/modules/puphpet/manifests/python
16  ./puppet/modules/puphpet/manifests/debian
28  ./puppet/modules/puphpet/manifests/apache
356 ./puppet/modules/puphpet/manifests
592 ./puppet/modules/puphpet
29512   ./puppet/modules
29912   ./puppet
30248   .


The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.