FreeKB - Linux Commands du (disk usage)
Linux Commands - du (disk usage)

Let's say John Doe has the following files and directories.

/home/john.doe/foo.txt
/home/john.doe/files/bar.txt

 

Assuming your present working directory is /home/john.doe, the du command without any options will return something like this.

  • 4 ./files means that the "files" directory contains 4 KB of files
  • 8 . means that there are 8 KB of files at and below the present working directory (/home/john.doe)
[john.doe@server001 ~]$ du
4       ./files
8       .

 

Often, it is much easier to use the --human-readable flag.

[john.doe@server001 ~]$ du --human-readable
4.0K       ./files
8.0K       .

 

The -s or --summarize flags can be used to provide a summary of the size of each directory, instead of each individual file. In this example, there are 8 KB of files at and below the present working directory (/home/john.doe).

[john.doe@server001 ~]$ du --human-readable --summarize
8.0K       .

 

The --exclude option can be used to exclude directories. In this example, the /home/john.doe/files directory is excluded.

[john.doe@server001 ~]$ du --human-readable --summarize --exclude /home/john.doe/files
4.0K       .

 

And here is how you an include hidden files and directories in the output.

[john.doe@server001 ~]$ du --human-readable --summarize $(ls -A /home/john.doe)
4.0K foo
2.5M .bar

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 2c1f6 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |