Reputation: 9
I have a VPS on Linode,and its storage is almost full,so I want to find out the largest directories,when I type in
du -hs * | sort -rh | head -30
it shows below:
top 30 large directories and this is the storage use:
storage useage It seems the storage useage doesn't match the total storage,is there anyone can tell me why,thank you
Upvotes: 0
Views: 3236
Reputation: 16263
I use this command for the root folder /
to check where the biggest directories are located, but you can use to any other directory of your choice
[sudo] du / -hxd 1 -t 1M | sort -hr
-h
from human-readable, print sizes in human readable format (e.g., 1K 234M 2G)-x
skip directories on different file systems-d
from depth, print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument-t
from threshold, exclude entries smaller than SIZE if positive, or entries greater than SIZE if negativeUpvotes: 1
Reputation: 4786
You can use this command for starters:
sudo du -h -x --max-depth=1 / | sort -hr
Where:
du - estimate file space usage
sort - sort lines of text files
And you will get the list of 1st level directories sorted by size in descending order. Next is to investigate based on the largest directories, what is eating all the space, using the same command above but replace the directory parameter from /
to the path you want to explore.
Upvotes: 2