Share with:


Every time package is removed via `apt-get remove`, a tiny piece of its configuration can be kept in your system. If you ever need to reinstall the package, this information can be re-used. These packages has status ‘rc’ in the output of `dpkg -l`. But if you want to keep your system tidy and clean, you may want them to be removed.

The miraculous command is

dpkg -l | egrep ^r | cut -d ‘ ‘ -f 3 | xargs apt-get remove –purge -y

What it does?

dpkg -l

list all packages

egrep ^r

print only those matching status ‘r*’. Package status is the first column, so add ‘^’ to match only the lines, beginning with ‘r’ symbol.

cut -d ‘ ‘ -f 3

return selected field only. Usually I add field separator symbol with ‘-d’ option and specify field number with ‘-f’

xargs apt-get remove –purge -y

xargs runs the specified command, appending input from STDIN (you can alter this behaviour vith options). In this case, i’m executing ‘apt-get remove –purge’ command. ‘-y’ swich means ”assume ‘yes’ to all questions” and is needed for apt-get to confirm the removal of packages.

The rest is the magic of pipes.

 

Why do i write this?

A strange messages were found in the syslog:

Errors when running cron:
    grandchild #2047 failed with exit status 1: 1 Time(s)
    grandchild #2205 failed with exit status 1: 1 Time(s)
    grandchild #2342 failed with exit status 1: 1 Time(s)
    grandchild #2658 failed with exit status 1: 1 Time(s)
    grandchild #2878 failed with exit status 1: 1 Time(s)
    grandchild #2972 failed with exit status 1: 1 Time(s)
    grandchild #30732 failed with exit status 1: 1 Time(s)
    grandchild #30832 failed with exit status 1: 1 Time(s)
    grandchild #30934 failed with exit status 1: 1 Time(s)
    grandchild #3094 failed with exit status 1: 1 Time(s)
    grandchild #31290 failed with exit status 1: 1 Time(s)
    grandchild #32395 failed with exit status 1: 1 Time(s)
    grandchild #3262 failed with exit status 1: 1 Time(s)

In-deep analysis revealed ‘/etc/cron.d/greylistclean’ from package ‘sa-exim’. I don’t use exim and it was replaced by postfix just after installing the system. The file mentioned did not show any signs of miss-formatting until a new version of cron daemon was installed via ‘apt-get dist-upgrade’