1

I'm writting instructions for someone else, and I want to know if I need to include a couple apt install commands in my snippet to make it completely copy/paste-able on a fresh Ubuntu installation.

How do I see if a given program was included with my Ubuntu installation or if I installed it myself later?

They're running the same Ubuntu version as me, so I don't need to know if the program only started being pre-installed in a certain Ubuntu version.

guntbert
  • 13,475

3 Answers3

0

The easy way to determine if a package is installed by the Ubuntu Desktop Installer is to check if it's included in the ubuntu-desktop metapackage. That's the metapackage that defines what the installer will install:

You can see the list of immediate dependencies using the command: apt depends ubuntu-desktop.

But what if your package is not listed among the immediate dependencies? You can easily find out by testing the package with apt.

For example, let's simulate the removal of nautilus (the Gnome file manager). We will, of course, use the --simulate flag; there is no need to destroy our system to answer this simple question. You can see below that removing nautilus also results in the removal of ubuntu-desktop. This is conclusive proof that nautilus is installed by the Desktop Ubuntu installer:

$ apt remove nautilus --simulate
NOTE: This is only a simulation!
      [...]
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gnome-shell-extension-desktop-icons nautilus nautilus-share ubuntu-desktop
  ubuntu-desktop-minimal
0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
Remv ubuntu-desktop [1.440]
Remv ubuntu-desktop-minimal [1.440]
Remv gnome-shell-extension-desktop-icons [19.10.2-1]
Remv nautilus-share [0.7.3-2ubuntu3]
Remv nautilus [1:3.34.1-1ubuntu1]

Let's expand on that example in two ways. Let's move down the dependency tree and try to remove a sub-dependency (nautilus-data). We do this by changing from remove to autoremove. Also, let's use grep to reduce the output. You can see below that this is an effective way to test any (sub-)dependency of ubuntu-desktop anywhere in the chain of dependencies. The nautilus-data package is installed by the Ubuntu Desktop Installer:

$ apt autoremove nautilus-data --simulate | grep ubuntu-desktop
  session-shortcuts tree ubuntu-desktop ubuntu-desktop-minimal
Remv ubuntu-desktop [1.440]
Remv ubuntu-desktop-minimal [1.440]

Let's look at the case with the opposite result. chrome is NOT a dependency of ubuntu-desktop. It was installed sometime later. Removing it WON'T remove ubuntu-desktop:

$ apt autoremove chrome --simulate | grep ubuntu-desktop
(No output)
user535733
  • 68,493
0

The apt-mark showmanual ... is close to what you want, but it lists things like updates of preinstalled things too. Put the below command string into a file, and run it as a script:

comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
ubfan1
  • 19,049
-1

I don't think there is any script or program that does what you want. About the only way to tell is to run the Ubuntu live USB and see if there are any programs not on it. A few programs do not get installed, like gparted, it is on 'live' but not on installed version. Have seen a few questions like this.

crip659
  • 571