Articles Comments

Complete, Concrete, Concise » Ubuntu, Ubuntu 11.10 » Ubuntu 11.10 – How to Completely Remove a Package

Ubuntu 11.10 – How to Completely Remove a Package

This tutorial shows how to completely remove or uninstall a package in Ubuntu 11.10. These instructions should work for other versions of Ubuntu, it’s derivatives (Edubuntu, Kubuntu, Lubuntu, Xubuntu) and other Debian based Linux distributions – but no guarantee is made.

This tutorial assumes you are comfortable with lower level operations in Ubuntu and know how to use apt-get. A brief introduction to apt-get can be found here.

NOTE: this introduction only covers the install aspect of apt-get. In this tutorial, we will see other apt-get commands: remove, autoremove, and --auto-remove

WARNING ! ! !

There is a small but real risk of data loss or making other programs or Ubuntu unusable.

Ensure you have a backup before proceeding

The Problem

A package is installed using either Ubuntu Software Center or apt-get. Later it is uninstalled, but you discover that not everything has been removed. Usually, this happens when you install and then uninstall one of the alternate Ubuntu desktops (Edubuntu, Kubuntu, Lubuntu, or Xubuntu) – the result is a mess.

This happens because a number of Recommended and Extra packages are installed along with the requested package. Unfortunately, many times, these Recommended and Extrapackages are not removed during uninstallation.

Example 1 – an easy to clean up install

Installing the package stellarium causes an extra package called stellarium-data to be installed as well:

richard@richard-VirtualBox:~$ sudo apt-get install stellarium
[sudo] password for richard: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  stellarium-data
The following NEW packages will be installed:
  stellarium stellarium-data
0 upgraded, 2 newly installed, 0 to remove and 100 not upgraded.
Need to get 35.6 MB of archives.
After this operation, 48.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? 

Uninstalling the package stellarium does not uninstall the extra package.

When using apt-get to remove stellarium (yellow) we are informed that an extra package had been installed (red) and should be removed using apt-get autoremove. The only package being removed by apt-get is the stellarium package (blue):

richard@richard-VirtualBox:~$ sudo apt-get remove stellarium
[sudo] password for richard: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer 
required:
  stellarium-data
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  stellarium
0 upgraded, 0 newly installed, 1 to remove and 100 not upgraded.
After this operation, 7,090 kB disk space will be freed.
Do you want to continue [Y/n]? 

Running the command apt-get autoremove removes certain types of packages. It removes packages that depend on other packages, but those packages no longer exist:

richard@richard-VirtualBox:~$ sudo apt-get autoremove
[sudo] password for richard: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  stellarium-data
0 upgraded, 0 newly installed, 1 to remove and 123 not upgraded.
After this operation, 41.1 MB disk space will be freed.
Do you want to continue [Y/n]? 

Those two steps of running the apt-get with the commands remove and autoremove can be combined into a single step. In this case, you specify the remove command and the --auto-remove flag / switch (yes, I know, it is spelled differently from the command, I have no idea why). This is how the Ubuntu Software Center runs the command when you use it to remove Remove a package:

richard@richard-VirtualBox:~$ sudo apt-get remove --auto-remove stellarium
[sudo] password for richard: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  stellarium stellarium-data
0 upgraded, 0 newly installed, 2 to remove and 100 not upgraded.
After this operation, 48.2 MB disk space will be freed.
Do you want to continue [Y/n]? 

Example 2 – a hard to clean up install

Not all recommended and extra packages that apt-get installs are easy to uninstall.

If you install one of the Ubuntu based desktops, like edubuntu-desktop, kubuntu-desktop, lubuntu-desktop, or xubuntu-desktop, you will find they install many recommended and extra packages. These extra packages might add to the experience of the installed package, but they don’t get removed when you uninstall the package. For example, installing lubuntu-desktop will also install the Abiword word processor, a number of games, the Chromium web browser along with many other packages.

Notice all the extra packages (blue) being installed along with lubuntu-desktop (yellow):

richard@richard-VirtualBox:~$ sudo apt-get install lubuntu-desktop
[sudo] password for richard: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  abiword abiword-common abiword-plugin-grammar 
  abiword-plugin-mathview ace-of-penguins audacious 
  audacious-plugins chromium-browser chromium-browser-l10n 
  chromium-codecs-ffmpeg elementary-icon-theme 
  esound-common galculator gdebi gdebi-core giblib1 
  gnome-icon-theme-full gnome-mplayer gnome-time-admin 
  gnumeric gnumeric-common gnumeric-doc gpicview guvcview
  hardinfo indicator-status-provider-pidgin leafpad libabiword-2.8 
  libaiksaurus-1.2-0c2a libaiksaurus-1.2-data 
  libaiksaurusgtk-1.2-0c2a libaudclient2 libaudcore1 libaudiofile0 
  libbinio1ldbl libcddb2 libcompfaceg1 libcue1 libdiscid0 libesd0 
  libexo-1-0 libexo-common libfluidsynth1 libfm-data libfm-gtk-data 
  libfm-gtk1 libfm1 libgdome2-0 libgdome2-cpp-smart0c2a 
  libgoffice-0.8-8 libgoffice-0.8-8-common libgringotts2 
  libgsf-1-114 libgsf-1-common libgtkmathview0c2a libimlib2 
  libjpeg-progs liblink-grammar4 libloudmouth1-0 libmcrypt4 libmcs1 
  libmenu-cache1 libmowgli2 libmusicbrainz3-6 libobrender27 libobt0 
  libonig2 libopenal1 libopts25 libots0 libpisock9 
  libresid-builder0c2a libsidplay2 libsvga1 libtar0 libuniconf4.6 
  libvdpau1 libwebcam0 libwv-1.2-3 libwvstreams4.6-base 
  libwvstreams4.6-extras libxfce4ui-1-0 libxfce4util-bin 
  libxfce4util-common libxfce4util4 libxfcegui4-4 libxfconf-0-2 
  libxvidcore4 link-grammar-dictionaries-en lm-sensors 
  lubuntu-artwork lubuntu-core lubuntu-default-settings 
  lubuntu-icon-theme lxappearance lxappearance-obconf lxde-common 
  lxde-core lxdm lxinput lxkeymap lxlauncher lxmenu-data lxpanel 
  lxpanel-indicator-applet-plugin lxrandr lxsession lxsession-edit 
  lxshortcut lxtask lxterminal mplayer mtpaint ntp obconf openbox 
  openbox-themes osmo pcmanfm pidgin pidgin-data pidgin-libnotify 
  pidgin-microblog plymouth-theme-lubuntu-logo 
  plymouth-theme-lubuntu-text python-xklavier scrot sylpheed 
  sylpheed-doc sylpheed-i18n sylpheed-plugins transmission ttf-lyx 
  uvcdynctrl uvcdynctrl-data wvdial xfburn xfce-keyboard-shortcuts 
  xfce4-power-manager xfce4-power-manager-data xfconf xfonts-100dpi 
  xpad xscreensaver
Suggested packages:
  gecko-mediaplayer gnumeric-plugins-extra epiphany-browser 
  docbook-xsl mesa-utils evince-gtk libmcrypt-dev mcrypt 
  libmcs-backend-gconf libmcs-utils jpilot pilot-link kpilot 
  gnome-pilot claws-mail nvidia-vdpau-driver vdpau-driver fancontrol 
  sensord read-edid i2c-tools indicator-application-gtk2 
  indicator-messages-gtk2 indicator-sound-gtk2 mplayer-doc netselect 
  fping ntp-doc menu ttf-dejavu libxml2-dev gnome-panel 
  kdebase-workspace-bin docker claws-mail-tools bsfilter 
  xfce4-power-manager-plugins xfs xserver xfishtank xdaliclock 
  fortune qcam streamer gdm3 kdm-gdmcompat
Recommended packages:
  amixer locales-all
The following NEW packages will be installed:
  abiword abiword-common abiword-plugin-grammar 
  abiword-plugin-mathview ace-of-penguins audacious 
  audacious-plugins chromium-browser chromium-browser-l10n 
  chromium-codecs-ffmpeg elementary-icon-theme esound-common 
  galculator gdebi gdebi-core giblib1 gnome-icon-theme-full 
  gnome-mplayer gnome-time-admin gnumeric gnumeric-common 
  gnumeric-doc gpicview guvcview hardinfo 
  indicator-status-provider-pidgin leafpad libabiword-2.8 
  libaiksaurus-1.2-0c2a libaiksaurus-1.2-data 
  libaiksaurusgtk-1.2-0c2a libaudclient2 libaudcore1 libaudiofile0 
  libbinio1ldbl libcddb2 libcompfaceg1 libcue1 libdiscid0 libesd0 
  libexo-1-0 libexo-common libfluidsynth1 libfm-data libfm-gtk-data
  libfm-gtk1 libfm1 libgdome2-0 libgdome2-cpp-smart0c2a 
  libgoffice-0.8-8 libgoffice-0.8-8-common libgringotts2 
  libgsf-1-114 libgsf-1-common libgtkmathview0c2a libimlib2 
  libjpeg-progs liblink-grammar4 libloudmouth1-0 libmcrypt4 libmcs1 
  libmenu-cache1 libmowgli2 libmusicbrainz3-6 libobrender27 libobt0 
  libonig2 libopenal1 libopts25 libots0 libpisock9 
  libresid-builder0c2a libsidplay2 libsvga1 libtar0 libuniconf4.6 
  libvdpau1 libwebcam0 libwv-1.2-3 libwvstreams4.6-base 
  libwvstreams4.6-extras libxfce4ui-1-0 libxfce4util-bin 
  libxfce4util-common libxfce4util4 libxfcegui4-4 libxfconf-0-2 
  libxvidcore4 link-grammar-dictionaries-en lm-sensors 
  lubuntu-artwork lubuntu-core lubuntu-default-settings
  lubuntu-desktop lubuntu-icon-theme lxappearance 
  lxappearance-obconf lxde-common lxde-core lxdm lxinput 
  lxkeymap lxlauncher lxmenu-data lxpanel 
  lxpanel-indicator-applet-plugin lxrandr lxsession lxsession-edit 
  lxshortcut lxtask lxterminal mplayer mtpaint ntp obconf openbox 
  openbox-themes osmo pcmanfm pidgin pidgin-data pidgin-libnotify 
  pidgin-microblog plymouth-theme-lubuntu-logo 
  plymouth-theme-lubuntu-text python-xklavier scrot sylpheed 
  sylpheed-doc sylpheed-i18n sylpheed-plugins transmission ttf-lyx 
  uvcdynctrl uvcdynctrl-data wvdial xfburn xfce-keyboard-shortcuts 
  xfce4-power-manager xfce4-power-manager-data xfconf xfonts-100dpi 
  xpad xscreensaver
0 upgraded, 145 newly installed, 0 to remove and 19 not upgraded.
Need to get 86.9 MB of archives.
After this operation, 315 MB of additional disk space will be used.
Do you want to continue [Y/n]? 

Uninstalling lubuntu-desktop using sudo apt-get remove lubuntu-desktop only removes the lubuntu-desktop package (yellow) but none of the other packages that were installed installed with it:

richard@richard-VirtualBox:~$ sudo apt-get remove --auto-remove lubuntu-desktop
[sudo] password for richard: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  lubuntu-desktop
0 upgraded, 0 newly installed, 1 to remove and 123 not upgraded.
After this operation, 32.8 kB disk space will be freed.
Do you want to continue [Y/n]? 

This is because none of those packages depend on lubuntu-desktop to function. They are recommended and installed because they contribute to the overall “Lubuntu experience”. They all have to be removed separately.

Next page -> “The Solution”

(page navigation is just under the Related posts at the bottom of the page).

Please consider sharing this article if you liked it or found it useful.

You may use one of the buttons below or share using your own favourite media.

Please do not republish this article on your website. You may publish a short excerpt and provide a link back to the original article.

Filed under: Ubuntu, Ubuntu 11.10 · Tags: , , , , , , , ,

6 Responses to "Ubuntu 11.10 – How to Completely Remove a Package"

  1. Mark D. says:

    I used apt-get autoremove to uninstall VirtualBox and it says it can’t locate file. I see it in my directories. But it doesn’t show up in my software center where I installed yesterday. Am I missing something. I don’t want to just remove the dir.

    1. admin says:

      I haven’t run VirtualBox inside of Ubuntu (I use it to run Ubuntu inside of Windows), but … the command to remove it should be sudo apt-get remove –auto-remove virtualbox-qt.

      Entering sudo apt-get autoremove instructs the installer system to automatically remove unused packages from the computer.

      Hope this helps and thanks for your question.

  2. Sul says:

    aptitude works great for removing those extra dependencies. Also, deborphan can help to find such packages.

    sudo aptitude purge package

    1. admin says:

      You can definitely do sudo apt-get autoremove to clean up unused dependencies (which I mention in the article) – and this works fine, but it does not uninstall everything, neither does <>deborphan.

      For example, if you install the Xubuntu desktop, in addition to installing the desktop, it also installs Abiword (among other things). Even if you use the autoremove option of apt-get or you run deborphan, Abiword and all the the applications installed along with Xubuntu desktop do not get uninstalled. Since none of those applications are orphaned (because you can always install them yourself without installing the Xubuntu desktop), the only way to clean them up is to remove them one by one.

      The proper way for the uninstaller to work is to read the installation log to determine what needs to be uninstalled.

      My solution (page 3 of this article) shows the user how to do this manually.

      An even better uninstaller would tell you which applications (if extra applications had been installed) were being removed and give you the choice of keeping the applications you want. On the other hand, a good installer would tell you which extra applications are being installed (apt-get at the commandline does this, but the info is not displayed in the Ubuntu Software Center) and give you the choice of installing them or not.

      Thanks for your comment.

  3. Marius says:

    Please, without command line nonsence… Is there any way to uninstall program with GUI?

    1. admin says:

      There is no available GUI interface that allows you to completely remove a package and all the other packages installed with it in one step.

      However, you can use Ubuntu Software Center to completely remove all packages – you just have to do it one package at a time.

      (1) determine which packages were installed – this means looking at the history.log to find out which packages were installed.

      (2) enter the package names (one at a time) into the Ubuntu Software Center and click on Remove

      There is an updated (for Ubuntu 12.04)) version of this article here. It is shorter and better expains the problem and solution.

      So far, I have not found any software package (with or without at GUI) that completely uninstall what was installed – they all use sudo apt-get remove --auto-remove <package name> (or its equivalent). As my article explains, in many cases, this leaves behind unneeded and unused packages.

      There are a number of packages that claim to clean up your system, but what they do is run sudo apt-get autoremove which removes some left behind packages. Others also run sudo apt-get purge which cleans out the repository cache (these are the files that are downloaded when you install something), but it does not remove the installed packages.

      This is a serious problem and people should complain about it to Linux developers.

Leave a Reply

%d bloggers like this: