Groups | Search | Server Info | Login | Register


Groups > alt.os.linux.mint > #47452

Re: Deleting old Kernels.

From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups alt.os.linux.mint
Subject Re: Deleting old Kernels.
Date 2026-05-10 03:36 +0000
Organization A noiseless patient Spider
Message-ID <10toufd$3rum$1@dont-email.me> (permalink)
References <10tlnbe$388pq$1@dont-email.me> <10tlpft$12ob4$1@paganini.bofh.team> <10tm2vj$3b5db$1@dont-email.me> <10tmdbl$3dibl$1@dont-email.me> <10tn1mb$3ijna$2@dont-email.me>

Show all headers | View raw


On Sat, 9 May 2026 12:18:51 +0200, jjb wrote:

> #1.   Find all installed kernels
> @lines = `dpkg --list | grep -i 'linux-image'`;
> foreach (@lines) {
>     if (/^ii\s+linux-image-(\d[\S]+)/) {
>        push (@kernels, $1);
>     }
> }

You can ask the dpkg commands for exactly the info you need, to save
parsing out unwanted cruft. Here’s what I came up with in Python:

    import subprocess

    kernel_list = subprocess.check_output \
      (
        args = ("dpkg-query", "-f" "${Package}\n", "-W", "*linux-image*"),
        text = True
      ).split("\n")[:-1]

    print(kernel_list)

Here’s (partial) output on my Debian Unstable system:

    ['linux-image-6.1.0-8-amd64', 'linux-image-6.1.0-8-amd64-unsigned',
        'linux-image-6.1.0-9-amd64', 'linux-image-6.1.0-9-amd64-unsigned',
        'linux-image-6.10.11-amd64', 'linux-image-6.10.11-amd64-unsigned' ...
        'linux-image-6.9.10-amd64', 'linux-image-6.9.10-amd64-unsigned',
        'linux-image-amd64', 'linux-image-generic']

Back to alt.os.linux.mint | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Deleting old Kernels. "Alan K." <alan@invalid.com> - 2026-05-08 18:16 -0400
  Re: Deleting old Kernels. George <Invalid@invalid.invalid> - 2026-05-08 23:45 +0100
    Re: Deleting old Kernels. "Alan K." <alan@invalid.com> - 2026-05-08 21:34 -0400
      Re: Deleting old Kernels. Paul <nospam@needed.invalid> - 2026-05-09 00:31 -0400
        Re: Deleting old Kernels. jjb <jjb@invalid.invalid> - 2026-05-09 12:18 +0200
          Re: Deleting old Kernels. Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-10 03:36 +0000
          Re: Deleting old Kernels. Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-05-10 04:36 +0000
            Re: Deleting old Kernels. jjb <jjb@invalid.invalid> - 2026-05-10 12:11 +0200
    Re: Deleting old Kernels. RonB <ronb02NOSPAM@gmail.com> - 2026-05-09 11:06 +0000
      Re: Deleting old Kernels. "Alan K." <alan@invalid.com> - 2026-05-09 09:03 -0400
  Re: Deleting old Kernels. german newsgroups <usualsuspectrider@gmail.com> - 2026-05-09 08:18 +0200

csiph-web