How to know the disk usage of your VPS

It is a simple task, and very common task for a VPS user.  You have a VPS, and want to know the disk usage of your data and system. You are also want to know which folder takes biggest disk space.

The command is du

<br />
du<br />


du takes a single argument, specifying a pathname for du to work; if it is not specified, the current directory is used. The SUS mandates for du the following options:

-a, display an entry for each file (and not directory) contained in the current directory
-c, display a grand total of the disk usage found by the other arguments
-d #, the depth at which summing should occur. -d 0 sums at the current level, -d 1 sums at the subdirectory, -d 2 at sub-subdirectories, etc.
-H, calculate disk usage for link references specified on the command line
-k, show sizes as multiples of 1024 bytes, not 512-byte
-L, calculate disk usage for link references anywhere
-s, report only the sum of the usage in the current directory, not for each file
-x, only traverse files and directories on the device on which the pathname argument is specified.


Above command usage method retrieved from Wikipedia.

Here is what I entered to get the result I want.



<br />
du -hx --max-depth=2 |grep G<br />

It will shown you the folders which took over 1GB.

–max-depth=2 means max depth of folder is two.
|grep G means at least 1GB. You can also use |grep M.

Following is another example.

<br />
du -hx --max-depth=2 |grep M<br />

Test the command in your VPS terminal window.