Most commonly used 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.
Usage:
root@server [/home/abl]# du -s /home/abl
213932 /home/abl
root@server [/home/abl]# du -sh /home/abl
209M /home/abl
root@server [/home/abl]# du -sch /home/abl
209M /home/abl
209M total
Listing all files and directories, switch “a”
# du -ah
a -> this switch displays disk usage of all individual files and directories.
Usage:
root@server [/home/abl/etc]# du -ah /home/abl/etc | tail
0 /home/abl/etc/wis.com/quota
4.0K /home/abl/etc/wis.com
0 /home/abl/etc/ftpquota
0 /home/abl/etc/quota
4.0K /home/abl/etc/cacheid
0 /home/abl/etc/ablo.com/passwd
0 /home/abl/etc/ablo.com/shadow
0 /home/abl/etc/ablo.com/quota
4.0K /home/abl/etc/ablo.com
28K /home/abl/etc
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”)
root@server [/home/abl/etc]# du -ah –exclude=”quota” /home/abl/etc | tail
4.0K /home/abl/etc/wis.abl.com
0 /home/abl/etc/wis.com/passwd
0 /home/abl/etc/wis.com/shadow
4.0K /home/abl/etc/wis.com
0 /home/abl/etc/ftpquota
4.0K /home/abl/etc/cacheid
0 /home/abl/etc/abl.com/passwd
0 /home/abl/etc/ablogsite.com/shadow
4.0K /home/abl/etc/ablogsite.com
28K /home/abl/etc