List protected packages

Hello, is there a way to list all packages that are protected? My goal is to clean the system from unnecessary packages that are not protected.

There are only a small number of packages that are protected.

Removing all non-protected packages would be…impactful

1 Like

Not that impactful for Fedora Workstation since GNOME would remain installed, and that already means a pretty high number of protected packages.

gnome-shell and anything it depends on would remain installed but you are still talking about a pretty destructive action.

These are all the protected packages on Fedora 35 Workstation install:

dnf
gnome-shell
grub2-efi-ia32
grub2-efi-x64
grub2-pc
grub2-tools-minimal
shim-aa64
shim-arm
shim-ia32
shim-x64
sudo
systemd
systemd-udev

Everything else is not protected. However, if removing something that isn’t protected would also remove one of those packages the operation should still be blocked.

2 Likes

That is where I was coming from though. Anyway, thank you for the list, could you share how you obtained it?

cat /etc/dnf/protected.d/*
3 Likes

Here is a close to complete “script” for the purposes I was aiming for, it merely lists unprotected packages, which includes iproute, wpa_supplicant, dhcp-client, pipewire, NetworkManager and there may be other necessities I might be missing that you SHOULD NOT uninstall.

#!/bin/sh

# lists protected packages
dnf repoquery --requires --resolve --recursive $(cat /etc/dnf/protected.d/*) | cut -d':' -f1 | sort | sed -E 's/-[0-9]$|-[0-9][0-9]$|-[0-9][0-9][0-9]$//g' | uniq > /tmp/protected.txt
cat /etc/dnf/protected.d/* >> /tmp/protected.txt
echo "kernel-core" >> /tmp/protected.txt

# lists installed packages
dnf list --installed | tail -n +2 | cut -d' ' -f1 | sed -E 's/\.x86_64$|\.i686$|\.noarch//g' > /tmp/installed.txt

grep -v -xF -f /tmp/protected.txt /tmp/installed.txt
rm /tmp/protected.txt
rm /tmp/installed.txt
1 Like
grep -v -x -f \
    <(dnf -q --qf=%{NAME} repoquery --requires --resolve --recursive \
        $(cat /etc/dnf/protected.d/*); echo kernel-core) \
    <(dnf -q --qf=%{NAME} repoquery --installed)
2 Likes

Not everybody running Fedora Workstation uses GNOME. Many of us use KDE or Xfce and that’s just the tip of the iceburg when it comes to DEs.

So as to not distract from the basic question and answer of how to get the list of currently protected packages, I’ve moved 22 posts to a new topic: Which packages make sense as “protected” in Fedora Workstation?

Sorry if I could result pedantic or fussy. Just a clarification. Fedora Workstation is the edition shipped with GNOME.
If you use Fedora Linux with another DE, it is not Fedora Workstation.