DISCLAIMER: This guide involves removing packages form your system. Be sure to backup your system before proceeding. I am not responsible for any damage that might happen for your system.
Introduction:
Note: This section is a clarification of how the process works. You don't have to read it. You can skip it if you want.
The purpose of this guide is to enable the user to remove any unnecessary packages on his ubuntu machine, so that his system contains only the packages he wants. There are two problems that face us when trying to remove unnecessary packages from the system:
- While the end user is aware of what programs he interacts with like his favorite browser and music player, he is not necessarily aware of all the other programs that have more subtle role in the operation of his machine. This will be taken care of on behalf of the user thanks to the brilliant debian package management system, and ubuntu's use of metapackages. More on this later. Suffices to say here that the user needs only be aware of the programs he interacts with on daily basis.
- Removing packages on linux system might lead to dependency problems. We might think that we don't need a certain package and try to remove it, only to find that it is required by another package that we need. Dealing with this manaully on a linux system with hundreds of packages installed can turn out to be a nightmare. Again this will be taken care of thanks to the debian smart package manager called aptitude.
A unique feature of aptitude is that it can label packages as 'automatically installed'. As far as aptitude is concerned an 'automatically installed' package only remains on the system if it is needed to satisfy a dependency of 'manually installed' package. Otherwise, it will be removed. Of course a 'manually installed' is package we have explicitly told aptitude that we need. You can learn more about this by consulting aptitude documentation.
Taking advantage of this feature of aptitude, we will label all the packages we want on our system as 'manually installed'. As for the rest of the packages, we are not going to directly uninstall them to avoid going into nightmare situation described above "dependency hell". Instead, we will just label them as 'automatically installed' and leave it to aptitude to automatically keep only the packages required by other 'manually installed' packages, and remove the packages which does not satisfy any dependency.
Ubuntu and metapackages:
A metapackage is an empty package that has no actual files. But it depends on other packages, so that when you install this dummy metapackage the system will have to install all the packages on which it depends. simply put, it is hook for installing its dependecies. For example, an Ubuntu user can install the Kubuntu environment (KDE and all its associated programs) by selecting "kubuntu-desktop." You can read more on metapackges here.
Ubuntu take advantage of metapackages beautifully. An Ubuntu system installed from a cd is comprised of following metapackages:
- linux-generic: This metapackage always depends on the latest generic Linux kernel available.
- ubuntu-minimal: This metapackage depends on all of the packages in the Ubuntu minimal system, that is a functional command-line system.
- ubuntu-standard: This metapackage depends on all of the packages in the Ubuntu standard system. This set of packages provides a comfortable command-line Unix-like environment.
- ubuntu-desktop: This metapackage this package depends on all of the packages in the Ubuntu desktop system. It installs a desktop environment (GNOME) and lots of software for home and office use.
So to install a complete ubuntu system, all you have to install is these four metapackages and apt will take care of the rest.
The process:
1. Install aptitude
Aptitude is no longer installed by default in ubuntu. We have to install it ourselves:
Code:sudo apt-get install aptitude
2. Delete old package states if present:
Code:sudo rm -v /var/lib/aptitude/pkgstates*
3. Mark all the packages installed on your system as "Automatically installed".
Code:sudo aptitude markauto ~i --schedule-only
Note: ~i is an aptitude search term meaning installed packages.
Note: Aptitude will want to remove any package that is marked as "automatically installed", so to prevent it form doing this ( until we do all the steps ) we will use the option --schedule-only from here on until we reach the final step. That is very important.
4. Label the packages we want to keep as 'manually installed':
Packages essential to the operation of your linux system is labeled as 'manually installed' by running the following command:
you can replace the part highlighted with magenta with your favorite packages. Remember to include xorg if you wish to have graphical system. You will also have to install a window manager like openbox. Other packages to install are file manager like pcamafm, panel, media player, internet browser .........Code:sudo aptitude install --schedule-only linux-generic ubuntu-minimal ubuntu-standard xorg openbox firefox lxpanel pcmanfm .......
Note: if there are any important packages required for a specific hardware you have, include it in the command above. e.g. wireless drivers
Note: You might want to use the -R switch with aptitude, this switch will prevent installing or keeping dependencies in the Recommend field
if you want to have only the packages that were isntalled by default with ubuntu modify the previous command to:
Code:sudo aptitude install --schedule-only linux-generic ubuntu-minimal ubuntu-standard ubuntu-desktop
if you want a complete command line system:
Code:sudo aptitude install --schedule-only linux-generic ubuntu-minimal ubuntu-standard
if you want a minimal command line system:
Code:sudo aptitude install --schedule-only linux-generic ubuntu-minimal
Here are some metapackages that you might be interested in installing
- ubuntu-restricted-extras: metapackage containing codecs and adobe flash
- gnome-core: barebones gnome
- gnome: The GNOME Desktop Environment, with extra components
- xfce4: Meta-package for the Xfce Lightweight Desktop Environment
- xubuntu-desktop: XCFE desktop with more bells and whistles
- lxde-core: barbone LXDE (lightweight X11 Desktop Environment)
- lxde: LXDE with extra components
- kde-full: KDE desktop
- kubuntu-desktop: KDE desktop with more bells and whistles
5. Let aptitude remove unncessary packages:
Now that we told aptitude what are the packages we want to keep (or add), it is time to let it do its magic.
First we will make aptitude run in simulation mode by using the -s switch. In this mode aptitude will not actually remove anything, it will just print a list of actions it would take if run in real mode (without the -s switch)
Code:sudo aptitude install -s
Examine the output of this command carefully and make sure you do not want any of the packages that are going to be removed. If you spot any packages in the output of the above command that you would like to keep, you can label it as 'manually installed' by running this command:
Also make sure that there are no confilcts. If you don't like what aptitude is going to do and want to revert back all the changes we did, run this command:Code:sudo aptitude install packagename --schedule-only
Code:sudo aptitude keep-all
After you are fully satisfied with what aptitude printed in the simulation mode. You can remove the pacakges using aptitude without the simulation switch:
Code:sudo aptitude install



Adv Reply

Bookmarks