11

I have tried searching for this but there seems to be no command that can output a list of packages (ideally in Ubuntu) that I have installed, not including any dependencies.

Stephen Kitt
  • 434,908
warsong
  • 485

3 Answers3

7
aptitude search '~i!~M!~E!~prequired!~pimportant'

will list all the packages which have been installed without being marked as automatically installed, excluding essential and required packages, which is pretty much what you're looking for. ~i lists packages which are installed, !~M filters packages which are marked as automatically installed, !~E filters essential packages, !~prequired and !~pimportant filter required and important packages. The latter three filters will catch quite a few packages installed by default.

On Ubuntu, you can add !~Rubuntu-desktop!~Rrecomends:ubuntu-desktop to filter out all the packages which ubuntu-desktop depends on or recommends, and which are installed by default:

aptitude search '~i!~M!~E!~prequired!~pimportant!~Rubuntu-desktop!~Rrecommends:ubuntu-desktop'
Stephen Kitt
  • 434,908
  • I had high hopes for this, but it seems that this command aptitude search '~i!~M!~E!~prequired!~pimportant' lists many files that: 1) were not installed by me, 2) that are required, essential and important. Tried this on a Raspberry Pi 5 'Lite' that has gotten "too fat" :) It seems there should be a better way? – Seamus Mar 29 '24 at 04:06
7
comm -23 <(apt-mark showmanual | sort -u) \
         <(gzip -dc /var/log/installer/initial-status.gz |
           sed -n 's/^Package: //p' | sort -u)

This gets the correct list of user-installed packages, to a better approximation than the answer from @Stephen Kitt.

agc
  • 7,223
warsong
  • 485
  • FWIW: Not complaining at all, just leaving a comment FYI: Neither of the answers posted give the correct result on my Raspberry Pi (3B+, Raspbian stretch) – Seamus Apr 06 '19 at 16:28
  • It seems this answer is more Ubuntu-centric – warsong May 27 '21 at 13:02
-1

The OP seems to want a list of: "packages (ideally in Ubuntu) that I have [he has] installed".

I read both of the answers here, and neither one came very close to giving me an answer to that same question for my Raspberry Pi. This was puzzling as I was able to get an answer using bash's history command:

history | grep "apt install"

This of course requires that one has a ~/.bash_history file. And obviously history won't give package dependencies, but perhaps the commands/files & tools mentioned in the other answers can help with that.

Seamus
  • 2,925