Tech Tip: Removing Unnecessary Packages on Debian Systems
The command deborphan can be used to check for unnecessary (orphaned) packages. By default deborphan searches for orphaned libraries, but you can have it search for other types of packages also: data packages, dev packages, etc. by specifying one of its many --guess-* command line options.
If you don't have deborphan installed you can install it via:
$ sudo apt-get install deborphan
Now, to remove all orphaned (library) packages simply run:
$ sudo deborphan | xargs apt-get -y remove purge
To remove all orphaned data packages run:
$ sudo deborphan --guess-dev | xargs apt-get -y remove purge
To see all the orphaned packages on your system run:
$ deborphan --guess-all
The following excerpt comes from the deborphan man page and relates to the --guess-* options:
deborphan can try to guess what packages may not be of much use to you by examining the package's name. It will pretend the package is in the main/libs section, and report it as if it were a library. This method is in no way perfect or even reliable, so beware when using this!
So it's usually a good idea to view the output of deborphan and make sure that it appears reasonable before feeding it to apt-get -y remove purge.
Trending Topics
| Dia - The Diagram Creation Tool | Feb 13, 2012 |
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
- Dia
2 hours 26 min ago - Service units, is a daemon
4 hours 2 min ago - Tcp
4 hours 22 min ago - Lamenting more development of Dia
10 hours 14 min ago - multiboot that works well for me
20 hours 4 min ago - What's a good, AFFORDABLE aka
20 hours 5 min ago - Employment Posters
1 day 11 hours ago - Sure the best distro is
1 day 12 hours ago - BeOS was the best
1 day 15 hours ago - I use Wireshark on a daily
1 day 20 hours ago





Comments
A less extreme aproach
I usually like to pipe it too markauto rather than immediately using purge so that aptitude gets a vote in the removal process.
test first:
deborphan --guess-all | xargs aptitude -ys markauto
then do it:
deborphan --guess-all | xargs aptitude -y markauto
then I remove all lingering configs with
test first:
aptitude search ~c
then do it:
aptitude purge ~c
Sorry, I ment
Sorry, I ment autoremove.
When i remove or purge something that was installed with "suggested" or with a lot of dependencys and something was left, the "autoremove" removes them.
For example I installed "extremetuxracer", "removed" it and used autoremove after:
sudo apt-get autoremove
Reading package lists ... Done
Building dependency tree
Reading state information ... Done
The following packages will be REMOVED:
extremetuxracer-date
libmikmod2
libsdl-mixer1.2
libsmpeg0
tcl8.5
0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
After this operation there will be released 37.4 MB of disk space.
Continue [Y / n] ? Y
(Reading database ... 62,198 files and directories currently installed.)
Removing extremetuxracer-date ...
Removing libsdl-mixer1.2 ...
Removing libmikmod2 ...
Removing libsmpeg0 ...
Removing tcl8.5 ...
Processing triggers for man-db ...
Processing triggers for menu ...
My man for apt-get:
APT-GET(8)
NAME
apt-get - APT package handling utility -- command-line interface
SYNOPSIS
apt-get [-sqdyfmubV] [-o= config_string ] [-c= config_file ] [-t= { target_release_name | target_
release_number_expression }] {update | upgrade | dselect-upgrade | dist-upgrade | install pkg [ { =pkg_version_number | /target_release_name } ] ... | remove pkg... | purge pkg... | source pkg [ =pkg_version_number ] ... | build-dep pkg... | check | clean | autoclean | autoremove | {-v | --version} | {-h | --help}}
autoclean
Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.
autoremove
autoremove is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed.
apt v:0.7.20.2+lenny1
Similar
Guess I was looking at an old man page, I didn't see the autoremove option (I use openSUSE so I'm not a regular apt-get user). I found a newer man page and yes it is there.
So, yes, autoremove is similar to deborphan but from what I read they don't always produce the same results (in terms of what they think can be removed).
Mitch Frazier is an Associate Editor for Linux Journal.
And what about apt-get
And what about apt-get auroremove ? Or apt-get autoclean ?
Different Thing Completely
That's something completely different, from the man page:
I don't see an "autoremove" option, or "auroremove" for that matter.
Mitch Frazier is an Associate Editor for Linux Journal.
See above
I was looking at an old man page, autoremove does exist, see the comment above.
I use openSUSE so I don't use apt-get very often.
Mitch Frazier is an Associate Editor for Linux Journal.
Status file is in an improper state
deborphan installed fine, but when I ran 'deborphan --guess-all' I got the error message below:
deborphan: The status file is in an improper state.
One or more packages are marked as half-installed, half-configured,
unpacked, triggers-awaited or triggers-pending. Exiting.
Any suggestions?
Check These
Check these two boogs:
Boog 1
Boog 2
(found at sidux).
Mitch Frazier is an Associate Editor for Linux Journal.
Thanks! I ran the command
Thanks! I ran the command below and it showed me which packages had an error.
egrep '^Status: |^Package: ' /var/lib/dpkg/status | egrep -B 1 'half-installed|half-configured|unpacked|triggers-awaited|triggers-pending'
deborphan works now.
doesn't aptitude do this?
How is this different from 'sudo aptitude purge ~c'?
Aptitude ~c
According to the aptitude manual:
On the other hand, deborphan attempts to find packages which are installed but which are no longer needed, at least not needed by any of the other installed packages.
Mitch Frazier is an Associate Editor for Linux Journal.