Gentoo Wiki


If you want to remove something so complex like KDE from your system and not leaving any dead packages, you should first ensure, that all your configuration files are in perfect state. For example, you should obviously remove all the relevant USE flags like the kde flag.



This is the essential world file. If you want a stable and clean system, you should keep it clean from dependencies. If you put a dependency into your world file, it will be upgraded in parallel with your programs. This means that it will stay behind when the programs that needed it are removed (or newer versions are installed that don't depend on it anymore), it will also be updated by the package manager regardless of whether anything is using it or not.


Most people will tell you to use emerge along with some quirky grep and sed commands, which even advanced users have problems to read. Not me. I will recommend you Paludis, a successor to Portage.

After installing sys-apps/paludis all you need to do is to run:

paludis --uninstall --with-unused-dependencies kde-meta

If you have more kde-like packages in your system you want get rid of just run the top command for all of them.

Using Portage+eix

The easiest way I've found, which requires neither installing + configuring Paludis nor cryptic grep/sed commands, is to just use Portage and eix together.

First, install and update eix (if you don't already have it):

# emerge eix
# update-eix

Then just remove the packages you want. As an example, this is how one could remove KDE-4 -- however this command can be modified, and is very powerful; see "man eix" for more information.

# emerge --ask --unmerge `eix --only-names --installed --slot "kde-4"`

In this case, everything that fills the slot "kde-4" (i.e. everything associated with KDE-4) will be unmerged. Then, to follow up, run depclean to get rid of any dependencies the previous command left laying around:

# emerge --depclean

NOTE: Running --depclean can be very dangerous if you don't make sure you know what it's going to remove. It's always a good idea to run it with --pretend first, check and make sure that you really don't need anything it lists, then run it normally. If something on the list to be removed is something you still need, you can make sure it is kept with:

# emerge --noreplace [package name]

Then, just make sure --depclean didn't break anything:

# revdep-rebuild
# emerge -avDuN world

Using Portage (emerge)

To cleanup a large package suite like KDE, portage doesn't appear to provide a built-in feature so you need to attack it directly. As mentioned above, the world file is located at /var/lib/portage/world, we need to perform a bit of text processing using grep to remove the KDE packages:

# mv world world.bak
# grep -v 'kde-base/' world.bak > world

If you aren't familiar with grep, the -v option inverts grep (causes it to output lines that don't match rather than ones that do). This essentially removes every kde package from the world which is very handy if you customised your install by emerging subsets of the meta packages rather than a blanket emerge kde-meta.

Now, to remove the packages all we need to do is ask portage to remove all "unused" packages:

# emerge --depclean

WARNING: Be careful of --depclean, always do an emerge -uDN world before using it or Bad Things May Happentm. Any packages emerged using "--oneshot" that aren't a dependency of something else that was not emerged with --oneshot will be removed by --depclean as well (as those packages aren't in the world either).


Once you've removed KDE, there are a few housekeeping tasks you may want to perform. If you have installed 3rd party KDE apps like amarok, those apps will still be installed (along with kde-base/kdelibs and any other assorted dependencies) and you will still need to purge those if you wish.

If you are doing a complete purge you may also want to remove your ~/.kde ~/.kde3.5. The /usr/kde directory may still exist as well, try equery belongs /usr/kde to find any additional packages that you may want to --unmerge as well which were missed by the first purge before using rm -rf /usr/kde.

Retrieved from ""

Last modified: Thu, 04 Sep 2008 00:27:00 +0000 Hits: 6,695