Groups | Search | Server Info | Login | Register


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

Re: Deleting old Kernels.

Path csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups alt.os.linux.mint
Subject Re: Deleting old Kernels.
Date Sun, 10 May 2026 03:36:13 -0000 (UTC)
Organization A noiseless patient Spider
Lines 30
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>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Injection-Date Sun, 10 May 2026 03:36:14 +0000 (UTC)
Injection-Info dont-email.me; logging-data="126934"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cxwuWo4tJOInx3k0qt7jd"; posting-host="d0440d15af103125b89cd250f7ef66f0"
User-Agent Pan/0.165 (Kostiantynivka)
Cancel-Lock sha1:CfwHDsRfeW+U8E/+04WdlAYQIYQ= sha256:9COHPYK6xNpwaciLqxVB+RU2RM5OO3X5ZfoBah7wGtY= sha1:8o0bJ99026YN9XQHfv0fryx88MQ=
Xref csiph.com alt.os.linux.mint:47452

Show key headers only | 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