39

Is there a equivalent of this command; yum list kernel-headers --showduplicates on Ubuntu with apt-get, apt-cache etc. The above command lists various versions of the kernel-headers rpm available on F20/RHEL or installations.

Closet I can get using apt-cache showpkg, not sure if there is a better way ?

$ apt-cache showpkg linux-image  
Package: linux-image  
Versions:   

Reverse Depends:  
  firmware-crystalhd,linux-image  
  systemtap,linux-image  
  fiaif,linux-image  
Dependencies:  
Provides:  
Reverse Provides:  
linux-image-3.13.0-27-lowlatency 3.13.0-27.50  
linux-image-3.13.0-27-generic 3.13.0-27.50  
linux-image-3.13.0-24-lowlatency 3.13.0-24.47  
linux-image-3.13.0-24-generic 3.13.0-24.47  
linux-image-3.13.0-24-lowlatency 3.13.0-24.46  
linux-image-3.13.0-24-generic 3.13.0-24.46  

Expecting similar output:

$ yum list kernel-headers --showduplicates
Loaded plugins: langpacks, refresh-packagekit
Installed Packages
kernel-headers.x86_64 3.11.10-301.fc20 @fedora
Available Packages
kernel-headers.x86_64 3.11.10-301.fc20 fedora 
kernel-headers.x86_64 3.14.4-200.fc20 updates

This would help me simply do a downgrade or upgrade to a specific version.

4
  • did you mean listing the version of all installed packages along with the package names? May 29, 2014 at 11:43
  • Both installed and uninstalled, similar to the above command:
    – askb
    May 29, 2014 at 11:45
  • 1
    Closest I could get was usingdpkg --list | grep linux-image
    – askb
    May 29, 2014 at 11:46
  • 1
    dpkg --list shows the details of all installed packages. May 29, 2014 at 11:47

4 Answers 4

25

You have the correct command, except linux-image isn't a real package name.

$ apt-cache show linux-image
N: Can't select versions from package 'linux-image' as it is purely virtual
N: No package found

apt-cache showpkg should work for real packages, though. e.g.

$ apt-cache showpkg lyx
Package: lyx
Versions: 
2.1.0-1~trusty~ppa4 (/var/lib/apt/lists/ppa.launchpad.net_lyx-devel_release_ubuntu_dists_trusty_main_binary-amd64_Packages) (/var/lib/dpkg/status)
 Description Language: 
                 File: /var/lib/apt/lists/ppa.launchpad.net_lyx-devel_release_ubuntu_dists_trusty_main_binary-amd64_Packages
                  MD5: 8c75d53cfd29c5b19c2172cb07b7fe9a

2.0.6-1build1 (/var/lib/apt/lists/ftp.iinet.net.au_pub_ubuntu_dists_trusty_universe_binary-amd64_Packages)

If you want to see all the versions of linux-image-like packages, you can just do a search, e.g.

$ apt-cache search linux-image | grep '^linux-image'

The problem is that the different versions of the kernel (linux-image) are in individual packages, and named independently according to the version. They are not all versions of the one package.


EDIT

This lists all available packages. To show which is installed, you can use dpkg -l. e.g.

$ dpkg -l lyx
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                           Version                      Architecture                 Description
+++-==============================================-============================-============================-==================================================================================================
ii  lyx                                            2.1.0-1~trusty~ppa4          amd64                        Document Processor

EDIT2

Another way to get information about different but similarly-named packages (e.g. linux-image*) is by using aptitude search.

$ aptitude search linux-image

You can also filter with grep using this awkward syntax to get around an aptitude bug/feature.

$ aptitude -w $COLUMNS search linux-image | grep '32 bit'

An i in the first column tells you that it's already installed. See man aptitude for the other characters.

5
  • the output which I get from yum clearly shows what is installed, uninstalled and available.
    – askb
    May 29, 2014 at 12:10
  • Okay. You should probably add this to your question, since many Ubuntu users (including myself) don't know what output yum produces. I've added more info in the answer.
    – Sparhawk
    May 29, 2014 at 13:18
  • @askb Thanks for the edit. As alluded to in my answer, I think part of the problem is that Ubuntu changes the name of each kernel depending on version, whereas Fedora uses the same name regardless of version. One advantage of the former is that you can have several versions installed at once, and rollback to an old version at grub if there are problems. In any case, the apt-cache search strategy should work.
    – Sparhawk
    May 30, 2014 at 3:04
  • thanks for the response, with rpm based installations its possibly several version of kernel installed as long as the versions are diff, but this is normally not applicable for all packages in rpm based installation or not straight forward AFAIK. However, I am still trying to find a clean way, where I have get details of both the installed and available (in repos) pkgs on ubuntu, as far as apt-cache search idea goes, its applicable to only local packages and does not look into the repos. The closest i could get was with showpkg
    – askb
    May 30, 2014 at 5:37
  • @askb No, apt-cache search looks in repos, not locally. AFAIK it doesn't tell you anything about locally installed packages. You need dpkg for that, as per my first edit. I've added in a second edit which is a single command applicable to kernels.
    – Sparhawk
    May 30, 2014 at 6:09
18

I think you're looking for the madison command in apt-cache:

apt-cache madison chromium-browser

Output:

chromium-browser | 50.0.2661.102-0ubuntu0.14.04.1.1117 | http://archive.ubuntu.com/ubuntu/ trusty-updates/universe amd64 Packages
chromium-browser | 50.0.2661.102-0ubuntu0.14.04.1.1117 | http://security.ubuntu.com/ubuntu/ trusty-security/universe amd64 Packages
chromium-browser | 34.0.1847.116-0ubuntu2 | http://archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages

Shows a quick reference of all available versions and the repo they come from. This is great if you use a PPA for a package and want to check the difference in versions between the PPA and the main repos.

More info on madison from the man page:

madison pkg...
           apt-cache's madison command attempts to mimic the output format and a subset of the functionality of the Debian archive management tool,
           madison. It displays available versions of a package in a tabular format. Unlike the original madison, it can only display information
           for the architecture for which APT has retrieved package lists (APT::Architecture).
0

You can use dpkg in order to see all installed packages:

$ dpkg --get-selections | grep -v deinstall | grep linux-image

Linux kernel meta-package is called on Debian linux-image-generic.

$ apt-cache madison linux-image-generic

will give you all versions available in APT repositories (not necessarily installed on your system).

-1

Have you tried to to boot an old kernel, and in the terminal enter:

showpkg kernel-header.list

and i think it might be in the boot directory, and all the kernel lays there, and this might work fine.

and then you can just type in to downgrade this in the terminal:

 sudo apt-get -y --force-yes purge linux-shim-efi shim-amd64-generic linux-shim-amd64 

and it might work fine this way.

5
  • I'm not sure what this means. There is no /dirctory, /directory or /grub on my system, and no file called kernel-headers.list. Also, reading a local file will probably not tell you what remote versions are available. -1 (but I'll revert if you can clarify).
    – Sparhawk
    May 30, 2014 at 3:03
  • I probably mean in /boot directory where the grub file lays.
    – Michael
    May 30, 2014 at 9:23
  • I have no file at /boot/kernel-headers.list. However, you can derive a list of installed kernels from (e.g.) /boot/grub/grub.cfg, but again, this is only the locally installed kernels, not the remote versions in the repos.
    – Sparhawk
    May 30, 2014 at 10:54
  • I do maybe no that it is the extension .cfg /boot
    – Michael
    May 30, 2014 at 14:21
  • I went through all files from find /boot -name '*.cfg', but none of them contain information about remote versions of the kernel.
    – Sparhawk
    May 31, 2014 at 0:03

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.