Monday, 3 October 2011

How to to list all packages by size for RPM and DEB

You might be experiencing an issue where you don't have enough space for "/" in your server. Usually, the biggest thing that consume the space is your software installed in the server.

So, for sure you want to remove the biggest software package installed on the server to recover back the space.

The question is, how do you list all packages installed and sort it by size?

I found the answer from this website:

The command that you should use is:

For RPM:
rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n

For DEB:
dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n

That's all. Remove the package by using Yum or Aptitude so that they can automatically find the correct dependencies for the removed package.