Linux: disk usage command – du

du is a standard unix command to calculate disk space from Unix/Linux system.

To get the sum space of the directory,


To get sum space with human-readable,

du -sh

To get sub directories space

du -sh *

To get sub directories space with all hidden folder,

du -sk .[!.]* * | sort -n

How to remove file older than 3 days

You might ask how to remove file that existed for 3 days or more.

It is quite straight forward and easy from Unix(Linux) command if you using find.

You may refer to the sample script as below.
find . -type f -mtime +3 -exec rm -rf {} \;

As the command above, it will find the file type of file and file existed for 3 days, execute the command of rm (remove). To be clear you may refer to the detail as below.
type – file type, you may define f for file and d for directory
mtime – It could be define that the last modified date and +3 is 3 days
exec – execution of your Linux command
\; – indicate that your command end

Alternatively,  you may use atime which last active time to replace mtime. Have fun.