How to remove all "rc" - residual packages using command line at once?

I give you some commands that will help you to find and remove broken packages and residual packages etc.

  • To find if any broken packages are there:

     sudo dpkg -l | grep "^iU"
    
  • To remove broken packages any of two commands will help:

     sudo apt-get -f install
     sudo apt-get remove --purge $(dpkg -l | grep "^iU" | awk '{print $2}')
    
  • To find the residual packages following command will help:

     sudo dpkg -l | grep "^rc"
    

Note: if any package is installed without any error, the first column starts with ii but for residual package it starts with rc, and for broken it starts with iU. For more information about package state letters, see this answer.

  • To remove all residual packages:

     sudo apt-get remove --purge $(dpkg -l | grep "^rc" | awk '{print $2}')
    

I wish after knowing these commands you'll be able to solve your problems. I'll be always waiting for your reply, if you need any help.


There is an easier way using aptitude:

To list the residual packages:

aptitude search ~c

To purge them:

sudo aptitude purge ~c

Source

Tags:

Xorg

12.04

Asus