3

is there a way to get a list of all the package names I have installed additionally to those that shipped with my copy of Ubuntu?

I didn't find options under the manual files of apt, dpkg and apt-get that seemed like they could do this kind of function.

EDIT to clarify: assuming Ubuntu came with packages a,b,c,d,e,f and I manually installed packages x,y,z, how can I get a list of x,y,z?

maze
  • 143
  • 4
  • 6
    Do a minimum research before asking, or if you did, make clear what you have tried, even if that didnt work out http://askubuntu.com/questions/2389/generating-list-of-manually-installed-packages-and-querying-individual-packages/492343#492343 – M. Becerra Oct 28 '16 at 15:09
  • @M.Becerra manually and automatically is different things than the question OP asked. Ubuntu mark all packages it installed by default as manual and that is not going to help – Anwar Oct 28 '16 at 15:41
  • 1
    @M.Becerra thank you, the commands in the answer there seem to be what i needed. I tried searching but had difficulty phrasing myself so resorted to making my own question; sorry/thanks! – maze Oct 28 '16 at 15:55
  • I'm voting this to reopen because, I think this is not a duplicate of the linked question. Reasons are 1. apt's manual and automatic are not same as manually installed by me and automatically installed by default. These are very different. – Anwar Oct 29 '16 at 08:48
  • @maze88 What do you mean by "I manually installed". Manually has two meanings in Apt world. If you install a package A and it brings B, C as dependencies, Only A is marked as manually installed. You want to see all A,B,C in the output or only the A? – Anwar Oct 29 '16 at 13:16
  • @Anwar Thank you for pointing this out. My goal was to have a list of what packages to reinstall if setting up a new system, so A would be sufficient. – maze Oct 29 '16 at 20:03
  • @maze88 OK then. – Anwar Oct 30 '16 at 06:21

1 Answers1

2

I believe there are better ways to do this, but this works.

First download the Ubuntu manifest file for your Ubuntu release

wget -c "releases.ubuntu.com/$(lsb_release -r -s)/ubuntu-$(lsb_release -r -s)-desktop-$(dpkg --print-architecture).manifest" -O ubuntu.manifest

Then generate the list of packages you have in your system and save it in a file called installed

dpkg-query -W -f='${binary:Package}\t${Version}\n' > installed

Then copy and paste this python code to a file naming pkg-diff.py (or whatever name you want)

f = open('ubuntu.manifest', 'r')

default = []
for line in f:
  default.append(line.split('\t')[0])

f2 = open('installed', 'r')
installed = []
for line in f2:
  installed.append(line.split('\t')[0])

extras = list(set(installed) - set(default))

print("\n".join(extras))

Finally execute the python script using the command in a terminal.

python3 ./pkg-diff.py

It should give you the list of packages you installed additionally.

Note: All files should be in same directory.

Anwar
  • 76,649