rpm -qa --queryformat '%{size} %{name}-%{version}-%{release}\n' | sort -k 1,1 -rn | nl | head -16

Display 16 largest installed RPMs in size order, largest first

Interesting to see which packages are larger than the kernel package. Useful to understand which RPMs might be candidates to remove if drive space is restricted.
Sample Output
$ rpm -qa --queryformat '%{size} %{name}-%{version}-%{release}\n' | sort -k 1,1 -rn | nl | head -16
     1	205734852 libreoffice-core-4.0.2.1-1.mga3
     2	145069876 google-chrome-stable-25.0.1364.172-187217
     3	126625991 metasploit-4.5-1.mga3
     4	126059188 gutenprint-foomatic-5.2.9-2.mga3
     5	110096290 libffmpeg-static-devel-1.1.2-1.mga3
     6	98677497 java-1.7.0-openjdk-1.7.0.6-2.3.8.1.mga3
     7	92598166 libgweather-3.6.2-2.mga3
     8	71248176 gnome-icon-theme-3.6.2-2.mga3
     9	57972204 gimp-2.8.2-3.mga3
    10	57019183 evolution-3.6.3-1.mga3
    11	49940798 samba-common-3.6.12-1.mga3
    12	46397791 kdebase4-workspace-4.10.1-1.mga3
    13	45481232 firefox-17.0.4-1.mga3
    14	42666340 kernel-desktop586-3.8.0-0.rc5.1.mga3-1-1.mga3
    15	42656290 kernel-desktop586-3.8.0-0.rc4.1.mga3-1-1.mga3
    16	42653069 kernel-desktop586-3.8.3-2.mga3-1-1.mga3

1
By: mpb
2013-03-19 21:10:54

These Might Interest You

  • Low on disk space? Check the largest installed RPMs for delete canditates. Show Sample Output


    2
    rpm -qa --qf '%{SIZE} %{NAME}\n' | sort -nr | nl | head -6 # six largest RPMs
    mpb · 2009-03-15 22:18:17 0
  • This, like the other commands listed here, displays installed arch packages. Unlike the other ones this also displays the short description so you can see what that package does without having to go to google. It also shows the largest packages on top. You can optionally pipe this through head to display an arbitrary number of the largest packages installed (e.g. ... | head -30 # for the largest 30 packages installed) Show Sample Output


    -1
    pacman -Qi | grep 'Name\|Size\|Description' | cut -d: -f2 | paste - - - | awk -F'\t' '{ print $2, "\t", $1, "\t", $3 }' | sort -rn
    GetterNoCheddar · 2012-11-20 03:40:55 0
  • I find it useful, when cleaning up deleting unwanted files to make more space, to list in size order so I can delete the largest first. Note that using "q" shows files with non-printing characters in name. In this sample output (above), I found two copies of the same iso file both of which are immediate "delete candidates" for me. Show Sample Output


    1
    ls -qahlSr # list all files in size order - largest last
    mpb · 2013-03-13 09:52:07 0
  • The other commands were good, but they included packages that were installed and then removed. This command only shows packages that are currently installed, sorts smallest to largest, and formats the sizes to be human readable. Show Sample Output


    0
    dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' `aptitude --display-format '%p' search '?installed!?automatic'` | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'
    EvilDennisR · 2013-07-26 23:18:20 0
  • Will work with filenames with spaces inside. Will not break in case of someone making directory that matches *.pm. And sorts from largest. Where largest is file size, not line count.


    0
    find . -type f -name '*.pm' -printf '%6s %p\n' | sort -nr | head -n 50
    depesz · 2011-02-09 16:19:11 0
  • List packages and their disk usage in decreasing order. This uses the "Installed-Size" from the package metadata. It may differ from the actual used space, because e.g. data files (think of databases) or log files may take additional space. Show Sample Output


    0
    perl -ne '$pkg=$1 if m/^Package: (.*)/; print "$1\t$pkg\n" if m/^Installed-Size: (.*)/;' < /var/lib/dpkg/status | sort -rn | less
    hfs · 2009-10-19 12:55:59 1

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: