Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How do you find all packages that were manually installed which are not a dependency of any other installed packages?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The short answer is: use aptitude like in the following:

aptitude -F%p search '?installed?not(?automatic)

But unfortunately this command returns many packages that match the query but are not what you expect, for two reasons:

  1. there are packages installed during initial installation of the system that result as non automatically installed

  2. packages installed as dependencies of a metapackage also can result as non automatically installed

The solution I came to some time ago is a match between the preceding command and the dpkg logs, that at least try to remove the influence of the point 1. in the preceding problems' list:

#!/bin/bash

export LC_COLLATE=C

eval $(lesspipe)

vars=($(less $(ls -rt /var/log/dpkg.log*) | grep 'status installed grub-pc' | head -1))
date="${vars[0]}"
time="${vars[1]}"

join \
  <(aptitude -F%p search '?installed?not(?automatic)' |
    sort) \
  <(less $(ls -rt /var/log/dpkg.log*) |
    awk -v date=$date -v time=$time '(($1 == date && $2 > time) || $1 > date) && $3 == "install" { print $4, $1, $2 }' |
    sort -u) |
  awk '{ print $2, $3, $1 }' |
  sort

This assume that grub-pc is the last package installed during initial installation, and is in no way perfect, but can give you a rough information to start from.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.