Closed Captioning Closed captioning available on our YouTube channel

How to use the du command: 2-Minute Linux Tips

Network World | Dec 20, 2019

In this Linux tip, we’re going to look at the du command that reports on disk usage – whether individual files or directories.

Similar
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the du command that reports on disk usage – whether individual files or directories.
$ du verylargefile.tgz
349304 verylargedile.tgz  more than 340 megabytes
The du command will generally default to reporting sizes in kilobytes (1024 bytes).
The -h (human-friendly) option adjusts the reported measurements to the file sizes, giving most of us a better feel for how large these files are.
$ du -h verylargefile.tgz
342M verylargefile.tgz  reported in megabytes
$ du -h smallerfile.bz2
268K smallerfile.bz2  reported in kilobytes
You can list the size of individual home directories along with a total for all directories by adding the -c option. We’re running as root so that we have the proper access to /home.
# du -s -c /home/*
28 /home/dorothy
64 /home/dory
28 /home/eel
28 /home/jadep
180 /home/nemo
732 /home/shark
39996840 /home/shs
44 /home/tadpole
39997944 total  grand total included
You can also show directory sizes along with the last update times by adding the --time option:
# du -s -c --time /home/*
28 2019-07-09 14:10 /home/dorothy
64 2019-06-17 08:40 /home/dory
28 2019-03-12 18:10 /home/eel
28 2019-07-16 14:21 /home/jadep
180 2019-11-25 09:28 /home/nemo
732 2019-05-07 12:02 /home/shark
39996840 2019-12-09 16:33 /home/shs
44 2019-10-16 04:06 /home/tadpole
39997944 2019-12-09 16:33 total

Closing: That’s your Linux tip for the du command. If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
Popular
Featured videos from IDG.tv