41

In Synaptic Manager I noticed I had a lot of packages in that list, and was wondering if any shouldn't be removed for some reason? Or if that is all safe to be removed. Is it possible that some should be kept, or does that show useless packages that should be cleared?

I have ran sudo apt-get autoremove but they are still there. (Also clean & autoclean)

What it is...

Trevor
  • 563

5 Answers5

65

As this question merged to here, there is need to provide some information which may helpful

From man apt-get:

       remove
           remove is identical to install except that packages are removed instead of installed. Note
           that removing a package leaves its configuration files on the system. If a plus sign is
           appended to the package name (with no intervening space), the identified package will be
           installed instead of removed.

       purge
           purge is identical to remove except that packages are removed and purged (any configuration
           files are deleted too).

So, when you remove package(s) usually by using Ubuntu-Software-Center or by sudo apt-get remove, it leaves its configuration files on system.

From community help,

While there is no built in way to remove all of your configuration information from your removed packages you can remove all configuration data from every removed package with the following command.

dpkg -l | grep '^rc' | awk '{print $2}' | xargs dpkg --purge

So, Run following command from terminal:

dpkg -l | grep '^rc' | awk '{print $2}' | sudo xargs dpkg --purge

This will removes configuration files from removed package.

Pandya
  • 37,289
50

Those listed package are just those that have configuration files that hasn't been removed. Unless you are planning to reinstall the packages again, and want to keep the configuration, yes, you can remove them safely. In synaptic, you can purge them by selecting them all, use the Package menu, then Purge. You can do this from the terminal too:

dpkg -l | grep '^rc' | awk '{print $2}' | xargs sudo apt-get purge
Braiam
  • 69,112
3

Another simple answer is with dpkg --get-selections.

dpkg --get-selections | grep 'deinstall$' | cut -f1 | xargs sudo apt --yes purge

dpkg --get-selections will briefly list packages, grep 'deinstall$' will select only those with configuration files left, without --yes the command will ask for confirmation but will not wait for user input(GNOME Terminal 3.48.1) and will terminate without doing anything.

Sam
  • 85
2

You could keep it all in apt and use the following command:

apt list | grep residual-config | cut -d'/' -f1 | sudo xargs apt -y purge

Can anyone provide a reason why this wouldn't work sometimes or is inferior to the answers above?

0

From this post:

To list packages that have been removed but still have configuration files left behind:

apt list '~c'

To remove the configuration files for packages that are no longer installed:

apt purge '~c'

but you probably want to run the latter as admin, with sudo apt purge '~c'.

These instructions seem to work fine, but I'm a noob about Ubuntu and apt, so I'd appreciate if anyone can point out possible drawbacks of these commands.

pglpm
  • 159