How to check disk space usage in Linux?
If we want to find out what occupies space on the server, we can use several commands.
We can use the command du.
du -kscx *
du -hc --max-depth=4 /dir | sort -h
You can also try the tool ncdu, https://dev.yorhel.nl/ncdu.
Another option is to use the find command.
find /home/ -size +1073700000c -print
The following command will display all files and folders sorted by MB.
du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}'
If you want to search only in a specific folder, you can use the following script.
The script also looks for files larger than 500000k.
find /home -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'