[How To] Clean up files left after removing packages
|As known, in Debian/Ubuntu Linux, it is possible to remove package with remove and purge command.
purge command removes package and all its files from the system, including configuration files too.
remove command removes only binary files.
The question how to find and remove files of packages that were removed earlier with remove command. In other word, how to clean up the system from unused and unnecessary files.
To view the list of all packages that were removed via remove command, but from which still left some files (configuration files at the system level, etc.), can do:
$ dpkg -l | awk '/ ^ rc / {print $ 2}'
files can be deleted by following command:
$ sudo dpkg --purge
Accordingly, combining these commands, we will find and delete all old files of already removed packages:
$ dpkg -l | awk '/ ^ rc / {print $ 2}' | xargs sudo dpkg --purge