How can I uninstall part of a package?
I have installed the BSD games package. Many of the games are awful or broken, so I wish to uninstall some of them without uninstalling others. Is there an easy way to do that? Currently, I’m sudo rm
ing them from usr/share/applications/bsdgames
and usr/games/
.
The point of packaging is that the packages are integral units.
So, there’s no easy way to do that, without breaking the packaging itself. You usually don’t want to do that.
Currently, I’m sudo rming them from usr/share/applications/bsdgames and usr/games/.
You especially don’t want to do that: the next software/distro update / rebuild will re-establish these, and also, generally, stay the hell away from things that your system installed using apt
.
Quite honestly, though: The whole package needs a total of 3.7 MB of space. That is roughly the same amount of data you use when you opened this very page. Just ignore the games you don’t like, there’s no measurable downside to you – 3.7 MB is nothing on a machine that runs ubuntu.
To uninstall part of a package, your approach is correct: if you know you don’t (and won’t) need a file shipped in a package, you can delete it (after all, it’s your system). However if you leave it at that, the next time the package is upgraded, the deleted files will be restored (unless they are configuration files in /etc
). To avoid that, you should tell dpkg
that you don’t want the files you removed: add a configuration file in /etc/dpkg/dpkg.cfg.d
, with lines of the form
path-exclude=/path/to/foo
for every file you deleted.
As Marcus says, this isn’t usually a great idea, and the dpkg
man page warns against it too. But there are circumstances where it is appropriate; one common setup is to remove documentation shipped with packages, or man pages in languages which no one using your computer needs or wants. I have a /etc/dpkg.cfg.d/locales
file containing
# Drop locales except English and French
path-exclude=/usr/share/locale/*
path-include=/usr/share/locale/en/*
path-include=/usr/share/locale/fr/*
path-include=/usr/share/locale/locale.alias
# Drop translated manpages except English and French
path-exclude=/usr/share/man/*
path-include=/usr/share/man/man[1-9]/*
path-include=/usr/share/man/en*/*
path-include=/usr/share/man/fr*/*
to avoid installing locale files and man pages in languages other than English or French.
Aggregate packages like bsdgames
are another situation where file removals can be useful; the disk space savings are probably not worth it, but removing candidates from your path can be worthwhile (assuming you are the only user of your system).