Let’s see all the packages marked as rc by dpkg. Know more about the state rc. This state means that the configuration files are not yet removed. You can see how a single package can be removed.
$ dpkg --list |grep "^rc" rc bsh 2.0b4-10ubuntu2 Java scripting environment (BeanShell) Versi rc devicekit-disks 007-2ubuntu6 abstraction for enumerating block devices rc devicekit-power 011-1ubuntu2 abstraction for power management rc dvipdfmx 1:20090115-1.2 A DVI to PDF translator with CJK support rc gnome-blackjack 1:2.28.0-0ubuntu3 Blackjack casino card game rc groovy 1.6.4-4ubuntu2 Agile dynamic language for the Java Virtual rc kdepim-runtime-data 4:4.3.2-0ubuntu1 shared data files for the KDE 4 base runtime
Let’s extract out the packages marked as rc
$ dpkg --list |grep "^rc" | cut -d " " -f 3 bsh devicekit-disks devicekit-power dvipdfmx gnome-blackjack groovy kdepim-runtime-data
Now let’s remove all the packages marked as rc.
$ dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge [sudo] password for abcde: (Reading database ... 239389 files and directories currently installed.) Removing bsh ... Purging configuration files for bsh ... Removing devicekit-disks ... Purging configuration files for devicekit-disks ... Removing devicekit-power ... Purging configuration files for devicekit-power ... dpkg: warning: while removing devicekit-power, directory '/var/lib/DeviceKit-power' not empty so not removed. Removing dvipdfmx ... Purging configuration files for dvipdfmx ... Removing gnome-blackjack ... Purging configuration files for gnome-blackjack ... Removing groovy ... Purging configuration files for groovy ... Removing kdepim-runtime-data ... Purging configuration files for kdepim-runtime-data ... Removing kdepim-runtime-libs4 ...
See how we have used xargs and the command dpkg –purge in combination.