dpkg --purge $(dpkg --list | grep ^rc | awk '{ print $2; }')
This constructs a list of packages which are removed but still have their configuration files installed (denoted by the ^rc pattern) and passes this list to the package management utility to purge all obsolete files. (source)
dpkg --list | grep ^rc | awk '{ print $2; }'