Blog

Disk usage: working with du command in linux.

Sometimes we need to work with disk usage in Linux terminals and work with files, such as finding the most critical files in the system for rogue backups or files or simply contraband.

Lets go with:

Find folder size in human readable [Gigs, Megs, Bytes…]

On the right we can see an example using du, with max-depth=1 [Meaning only the root].

du command

$ du -a
0   ./redhat/rh7
4   ./redhat
4   ./testfile.txt
0   ./linuxKernel
0   ./ubuntu/ub10
4   ./ubuntu
16  .

du human readable

$ du -ah
0   ./redhat/rh7
4.0K    ./redhat
4.0K    ./testfile.txt
0   ./linuxKernel
0   ./ubuntu/ub10
4.0K    ./ubuntu
16K .

du exclusion

du -cbha --exclude="*.txt"
0   ./redhat/rh7
4.0K    ./redhat
0   ./linuxKernel
0   ./ubuntu/ub10
4.0K    ./ubuntu
12K .
12K total

du custom display type.

$ du -cbha --time
0   2012-05-22 21:52    ./redhat/rh7
4.0K    2012-05-22 21:52    ./redhat
3   2012-06-18 19:23    ./testfile.txt
0   2012-05-22 21:52    ./linuxKernel
0   2012-05-22 21:52    ./ubuntu/ub10
4.0K    2012-05-22 21:52    ./ubuntu
13K 2012-06-18 19:23    .
13K 2012-06-18 19:23    total
ddemuro
administrator

Sr. Software Engineer with over 10 years of experience. Hobbist photographer and mechanic. Tinkering soul in an endeavor to better understand this world. Love traveling, drinking coffee, and investments.

You may also like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: