Blog

Disk usage: working with du command in linux.

Sometimes we need to work with disk usage in linux terminals, and working with files as for example to find biggest 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

You may also like

The perfect server.
LUKS Drive Encryption

Leave a Reply

Recent Comments