Ubuntu – Why removing gnome-core does not remove all of it’s dependencies

aptmetapackagesuninstall

I installed gnome-core package on Ubuntu (minimal version for the beagle bone) and it was almost 600mb. However, when I try to un-install it using

sudo apt-get autoremove gnome-core 

It removes only 49 MB. Any Ideas, how to remove the entire 600 MB?

Best Answer

gnome-core is a meta package and the case with meta packages is --

They pull packages to get installed but removing them will not remove all the pulled packages.

So, unless, you have copied the names of packages installed by gnome-core, it is virtually impossible to remove all the 600 MBs.

But, you can get the names of pulled packages by the command

apt-cache depends gnome-core 

and try to remove the packages one by one. You should check always whether it is removing any necessary packages.

Or you can get the list of packages in more useful way by this:

apt-cache depends gnome-core | cut -f 2 -d ':'  | tr '\n' ' '

This will list all the dependencies of gnome-core package, ignore the package name in <> marks only.

How do I know, whether any system package is being removed?

When you see a lot of space is being freed from the command, (more that 600MB), you should know that you are removing more than you installed. apt-get will let you know how much space is going to be freed, before removing like with a message like this

After this operation, 384 kB disk space will be freed.

And When you try to remove essential system package, apt-get will show you a warning message.

Recommendation: I suggest you to get a list of packages from the first command, and try to remove them one by one. It is safer. If you see a warning, skip removing that package. I see, most of the packages in gnome-core are related with GUI, I guess removing those packages will not harm your system (if you don't want a GUI).

Hope this helps!


Some note on removing packages

How pulled packages get uninstalled when you remove the master package ?

When you install a package and that package depends on some other packages, the dependency packages also get installed and Marked as auto. That means, the Apt system mark them as Automatically installed as dependency of another package. It helps Apt system to recognize unnecessary packages.

When, you uninstall the master package, the pulled packages are also marked as obsolete or unnecessary packages in the system. You can remove them by providing autoremove option to apt-get. (aptitude automatically remove them with the master package).

An exception to this rule is, if you later install another package which also depends on the pulled packages, the pulled packages will not be marked as obsolete when you remove the first master package.

Example: You installed a package X that depends on package Y. When you installed X, Y also gets installed and marked as auto. If you do not install another package Z which also depends on Y, removing X will render Y's usefulness and Apt system will mark it obsolete and you can remove it with autoremove option.

But If you install a package Z after X which also depends on Y, then removing only X does not mark Y as obsolete package and you can't remove it with autoremove option

But note that if you remove package Y after installing X, it will remove package Y including X, because X can't stay without Y and you wanted you remove Y, that means you also wanted to remove X. Apt will remove X automatically when removing Y unlike marking it obsolete to later removal by autoremove option.

Try out examples: ubuntu-desktop package is a meta package. It was used to install the standard Ubuntu desktop. Try removing it, only that package will be removed.

Also try installing lubuntu-desktop package (You may not want to install this, because it is a big download). But, when you try to remove it, only the tiny package lubuntu-desktop will get removed.

Apt handles meta packages differently

The meta packages like gnome-core, ubuntu-restricted-extras are also called virtual packages. They are called so, because they are basically empty packages, They pull other packages by depending on them. For example, ubuntu-restricted-extras depends on (in 12.04) following packages:

ubuntu-restricted-addons
ttf-mscorefonts-installer
unrar
gstreamer0.10-plugins-bad-multiverse
libavcodec-extra-53

Where, ubuntu-restricted-addons itself is another meta package. Since, meta packages are used for only pulling packages, installing them does not mark the pulled packages as auto, they are marked as manually installed. The result? Removing only the master meta package will not mark the pulled packages obsolete and you can't remove them by autoremove option. That is why you need to remove each pulled package of the meta packages manually.

Example: You installed a meta package X that depends on packages Y and Z. When you installed it, the Y and Z packages aren't marked as auto (automatically installed as dependency of another package), instead they marked as manually installed. In later time when you want to remove X, only the virtual X package gets removed. Both, Y and Z, remain in the system and you can't uninstall them with autoremove option.