I go to Cyber Security competitions, in which I am given an image that is tampered with, making it insecure. One of the steps of securing the image is to get rid of "bad" or "unofficial" packages.

What I want to know is how far off from a clean, fresh installation the current machine is, and look at a human-friendly list of deltas.

I want to do this by getting a list of packages that would be installed on a fresh install, and comparing it to the list of actually installed packages on the machine I am working on.

How do I get that list of fresh install packages?

I need answers for both Ubuntu server and Ubuntu desktop. (Both would be LTS versions.)

  • Currently there are 3 LTS with support, 16.04, 14.04 and 12.04 (until April). All have different packages.
    – user589808
    Feb 17, 2017 at 3:32

1 Answer 1


dpkg --get selections | grep install will give you the list of packages (approx 3500-4000 on an Ubuntu Desktop system) that is apt-marked for installation on your system.

Note that this may be slightly different from what actually is currently installed. Apt looks for that delta each time it runs, and tries to install or remove any changes.

Another method is to use dpkg -l. Both methods list the contents of the dpkg database, with differing levels of detail and with different output formats.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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