List your largest installed packages.

dpkg --get-selections | cut -f1 | while read pkg; do dpkg -L $pkg | xargs -I'{}' bash -c 'if [ ! -d "{}" ]; then echo "{}"; fi' | tr '\n' '\000' | du -c --files0-from - | tail -1 | sed "s/total/$pkg/"; done
Calculates the size on disk for each package installed on the filesystem (or removed but not purged). This is missing the | sort -rn which would put the biggest packges on top. That was purposely left out as the command is slightly on the slow side Also you may need to run this as root as some files can only be checked by du if you can read them ;)
Sample Output
176     acl                                                                                                                                     
44      acpi                                                                                                                                    
396     acpi-support                                                                                                                            
32      acpi-support-base                                                                                                                       
108     acpid                                                                                                                                   
524     adduser                                                                                                                                 
408     akonadi-server                                                                                                                          
2416    akregator                                                                                                                               
388     alsa-base                                                                                                                               
1840    alsa-utils                                                                                                                              
1860    amor                                                                                                                                    
96      anacron                                                                                                                                 
120     apmd                                                                                                                                    
4512    apt                                                                                                                                     
104     apt-file                                                                                                                                
376     apt-utils                                                                                                                               
140     apt-xapian-index                                                                                                                        
9184    aptitude                                                                                                                                
112     at                                                                                                                                      
104     avahi-autoipd                                                                                                                           
252     avahi-daemon                                                                                                                            
260     base-files                                                                                                                              
100     base-passwd                                                                                                                             
du: cannot access `diverted by dash to: /usr/share/man/man1/sh.distrib.1.gz': No such file or directory                                         
du: cannot access `diverted by dash to: /bin/sh.distrib': No such file or directory

By: pykler
2009-10-12 14:57:54

9 Alternatives + Submit Alt

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? 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.


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: