Some useful “du – disk usage” command usages – Unix/Linux

DU command – The “disk usage” command is used to check the disk usage of files and folder under Unix/Linux system. It has a wide range of options. It’s one of the commonly using command by server/system administrators. A lot of switches are available with “du” command to manage things simply. Here I’m listing some important switches with du command to simply your workload on CLI.

Other switches are available with du. Please see man page or du --help for more details.

Most commonly using form

# du -sch

h -> human readable format.
c -> display a total size usage at the end of result.
s -> display total size of a file or total size of all files in a directory.


[[email protected]] du -s /home/server/
52    /home/server/

[[email protected]] du -sc /home/server/
52    /home/server/
52    total

[[email protected]] du -sch  /home/server/
52K    /home/server/
52K    total

Displaying du command output with size specification

# du -(k,m,g)

k -> output displays in KB
m -> output displays in MB
g -> output displays in GB

Listing output with time stamp

# du –time

Command usage:

[[email protected]] du -sch –time  /home/server/
52K    2013-09-02 18:39    /home/server/
52K    2013-09-02 18:39    total

disk usage

Listing all files and directories, switch “a.”

# du -ah

a -> this switch displays disk usage of all individual files and directories.


[[email protected]] du -ah /home/files/
0    /home/files/EcLinux5.doc
0    /home/files/EcLinux3.doc
0    /home/files/EcLinux4.txt
0    /home/files/EcLinux4.doc
0    /home/files/EcLinux2.txt
0    /home/files/EcLinux5.txt
4.0K    /home/files/EcLinux1.doc
0    /home/files/EcLinux3.txt
4.0K    /home/files/EcLinux1.txt
0    /home/files/EcLinux2.doc
12K    /home/files/

Exclude something from the command output, using –exclude

# du –exclude

-–exclude -> This switch will avoid the particular file name that we have mentioned.
In the below example du -ah avoid files ending with .txt (–exclude=”*.txt”)

[[email protected]] du -ah –exclude=”*.txt” /home/files/
0    /home/files/EcLinux5.doc
0    /home/files/EcLinux3.doc
0    /home/files/EcLinux4.doc
4.0K    /home/files/EcLinux1.doc
0    /home/files/EcLinux2.doc
8.0K    /home/files/

Well, try this on your black screen 🙂

Write a comment if you have any questions.

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *