Find largest files on CentOS
Today I had a problem with a server where mysql would not start anymore. When starting mysql I got an error message saying:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
So I had a look in my mysql log file (located at /var/log/mysqld.log) and noticed there was no more space on the server.
I needed to know which files were causing this problem and there is a nice command to do this:
Type this command at your shell prompt:
du -a /var | sort -n -r | head -n 10
It gives you the 10 largest files in the /var directory. If you want to search your entire server just change /var to /
And if you want more than 10 results just change the number 10 at the end to any number you like.
To see how much free disk space you have left, just type: