Ubuntu – Safely removing *unused* packages


After various linux beginner's experiments my Kubuntu system keeps telling me that there are unused packages that are not needed anymore and that should be removed. This sounds like a good idea to me.

This is what "apt-get -s autoremove" proposes for removal:

  freeglut3 fs-uae fs-uae-launcher gir1.2-gtksource-3.0 hwdata ipython kmymoney-common libalkimia4 libexosip2-11 libglee0d1 libgnome-desktop-2-17 libgtksourceview-3.0-1 libgtksourceview-3.0-common
  libgwengui-cpp0 libgwengui-qt4-0 liblinphone5 libmediastreamer-base3 libofx6 libosip2-11 libosp5 libpanel-applet0 libportmidi0 libpyside1.2 libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0-0
  libsensors-applet-plugin0 libshiboken1.2 libsmpeg0 linux-headers-3.19.0-15 linux-headers-3.19.0-15-generic linux-image-3.19.0-15-generic linux-image-extra-3.19.0-15-generic meld python-dulwich
  python-fastimport python-numpy python-opengl python-pexpect python-pygame python-pyside python-pyside.phonon python-pyside.qtcore python-pyside.qtdeclarative python-pyside.qtgui python-pyside.qthelp
  python-pyside.qtnetwork python-pyside.qtopengl python-pyside.qtscript python-pyside.qtsql python-pyside.qtsvg python-pyside.qttest python-pyside.qtuitools python-pyside.qtwebkit python-pyside.qtxml
  python-simplegeneric python-svn

For most of them I have no idea in which context I installed them. But at least one of these packages is definitely NOT unused: The emulator "fs-uae" was manually installed by me and I intend to continue using it.

Why does apt-get propose to remove the "fs-uae" package? Is there a way to cleanup with breaking anything and without removing something I need?

Best Answer

As you probably already know, in Linux packages may specify "dependencies", that is other packages that must be installed in order for this package to actually work. These dependencies are resolved recursively, that is dependencies of your package dependencies are installed as well. This way meta-packages may exist that will install entire set of software. Common examples are libreoffice (for office suite) or kde-full for entire KDE desktop.

When apt (Debian package manager) installs some package, it marks all dependencies as automatically installed. This way it can distinguish between packages explicitly requested by user and packages that were pulled in merely as dependencies (about which user most likely don't care at all).

apt-get autoremove looks up for packages that are marked as automatically installed, but which are no longer needed by any manually installed packages. These are often older versions of libraries (when version of library is in package name to allow different versions to coexist, e.g. libavcodec54 and libavcodec56) or packages removed from repository, but sometimes some useful application gets pulled in as dependency and then is removed. This happens especially when you first tell apt to install recommended or suggested packages, but then configure it to not pull in these packages as dependencies.

To remove package from list of packages considered for removal, mark that package as installed manually. You can do it using apt-mark:

apt-mark manual <package_name>

or aptitude (following commands are equivalent, use only one):

aptitude unmarkauto <package_name>
aptitude install <package_name>
aptitude install <package_name>&m

Finally, to get some context when these particular packages were installed, you can try searching their names in /var/log/apt/history.log files. These logs are rotated (compressed and put in separate file) monthly; to get the full archive, you can run (order will not be preserved):

cat /var/log/apt/history.log > /tmp/full-archive
zcat history.log* >> /tmp/full-archive
Related Question