How do I get the real full package name (including the version) that would be installed if I ran apt-get install pseudo-package-name?

This is related to this previous question: Get the kernel version from lts package?


apt-get install linux-image-generic-lts-trusty

would install (as of right now on my 32-bit Trusty server):


I've tried the following, but none give me the answer. I'm trying to script this so I can just grab the linux-headers.

$ sudo apt-get install -qqs linux-image-generic-lts-trusty
Inst linux-image-generic-lts-trusty ( Ubuntu:14.04/trusty-updates [i386])
Conf linux-image-generic-lts-trusty ( Ubuntu:14.04/trusty-updates [i386])
$ apt-cache depends linux-image-generic-lts-trusty
  Depends: linux-image-generic
$ apt-cache depends linux-image-generic
  Depends: linux-image-3.13.0-35-generic
  Depends: linux-image-extra-3.13.0-35-generic
  Depends: linux-firmware
$ apt-cache policy linux-image-generic-lts-trusty
  Installed: (none)
  Version table: 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/main i386 Packages 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages

After some exploration of /var/lib/{apt,dpkg}, I relealized that there's not a generic, scriptable answer to this problem. So, similar to the answers below from @mchid and @muru, I did it like this:


linux_package_version=$(apt-cache policy $metapackage |\
    sed -nE '/Candidate:/ s,[^[:digit:]]*([[:digit:]\.]+)\.([[:digit:]]+)\.[[:digit:]]+,\1-\2,p')

apt-get download linux-headers-${linux_package_version}-generic linux-headers-${linux_package_version})

3 Answers 3


First, you must show exactly what package the metapackage provides:


apt-cache show linux-image-generic-lts-trusty | grep Depends:


Depends: linux-image-generic
Depends: linux-image-generic

Now, if you type the specific package of the metapackage you will get your exact result:

apt-cache show linux-image-generic | grep Depends:


Depends: linux-image-3.13.0-35-generic, linux-image-extra-3.13.0-35-generic, linux-firmware
Depends: linux-image-3.13.0-24-generic, linux-image-extra-3.13.0-24-generic, linux-firmware

The newest version is always installed unless otherwise specified like in the following example:

sudo apt-get install linux-image-3.13.0-24-generic

Alternatively, if you just want the version you could type the following command or a variation there of instead:

apt-cache show linux-image-generic-lts-trusty | grep Version:


  • I ended up digging around in /var/lib/{apt,dpkg} and realized that there's no absolute answer. Since I was looking for the linux version explicitly, I tailored my solution using similar techniques above. I'll post my exact answer at the end of the question.
    – Harvey
    Sep 17, 2014 at 19:48

The problem is the dependency:

└── linux-image-generic
    └── linux-image-3.13.0-35-generic

Because of this, you may not directly get information on which package will be installed. You'll need to use something like apt-rdepends.


In general you cannot. There are packages such as "email-client" that do not provide a dependency chain that can be followed and resolved.

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.