Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Lawrence =?iso-8859-13?q?D=FFOliveiro?= 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> 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 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']