Sreyan Chakravarty wrote:
How do I remove a specific version of a package using DNF ?
Refer to the "SPECIFYING PACKAGES" section in the dnf man
page. It explains the syntax options you can use to specify
a <package-spec>, which is used by many dnf commands, like
dnf remove.
While there, the remove-n, remove-na, and remove-nevra
commands are also worth reading about. They come in handy
occasional.
These are the installed packages for 5.7:
$ dnf list installed kernel-* | grep -i 5.7
Perhaps this is a minor point, but it's good to get in the
habit of escaping shell wildcard characters, like '*' in the
above command. You can do that either with quoting
('kernel-*') or prefixing the wildcard character with a
backslash (kernel-\*).
Not escaping the '*' _appears_ to work as expected -- until
you run it in a directory where a pathname matches kernel-*.
Then, you find out the shell expands the glob first, before
dnf has a chance to see the argument you intended.
kernel-core.x86_64 5.7.10-201.fc32
kernel-devel.x86_64 5.7.10-201.fc32
kernel-headers.x86_64 5.7.10-200.fc32
kernel-modules.x86_64 5.7.10-201.fc32
kernel-modules-extra.x86_64 5.7.10-201.fc32
How exactly do I remove these ?
As you'll find in the man page, dnf accepts glob patterns,
which are much like shell glob patterns. You can use them
to remove all 5.7 kernels, something like:
$ sudo dnf remove 'kernel*-5.7.*'
Similarly, you can use the patterns to avoid the need for
the pipe to grep above (which also didn't need the -i
option, as your argument is numeric):
$ sudo dnf list installed 'kernel*-5.7.*'
HTH,
--
Todd