how to detect space usage in linux

Getting the size of all files and folders inside the current directory can be done by typing:

 ls | xargs du -s -BM

Get filesize in descending order from all files in a recursive folder structure

find . -type f -exec du -a -h --max-depth=100 {} + | sort -hr

Another quite handy tool is ncdu. It provides you the disc usage in a graphical way on the shell. Install it like this:

sudo apt-get install ncdu

List folders bigger 1Mb and list them in descending order

du -sm * | awk '$1 > 1' | sort -n -r

List the ten largest folders inside a recursive folder structure

find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}