'Error while installing package: installed grub-efi-amd64 package post-installation script subprocess returned error exit status 255

I recently started using KDE Neon as my primary Operating system on my Dell XPS Laptop. I typically use Discover to install system updates. However off late I have been getting this error message when installing any system update.

Fatal error: Error while installing package: installed grub-efi-amd64 package post-installation script subprocess returned error exit status 255

I looked around online for help and tried a few suggestions like apt install --reinstall grub-efi-amd64 AND dpkg --configure -a and I see the below message on the terminal. I do not recollect interrupting any update on the machine. This system is a UEFI system with EFI partition on /boot/efi

Setting up grub-efi-amd64 (2.04-1ubuntu26.2) ...
od: /sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c: Operation not permitted
/usr/share/grub/grub-check-signatures: 22: [: Illegal number: 
dpkg: error processing package grub-efi-amd64 (--configure):
 installed grub-efi-amd64 package post-installation script subprocess returned error exit status 255
dpkg: dependency problems prevent configuration of grub-efi-amd64-signed:
 grub-efi-amd64-signed depends on grub-efi-amd64 | grub-pc; however:
  Package grub-efi-amd64 is not configured yet.
  Package grub-pc is not installed.

dpkg: error processing package grub-efi-amd64-signed (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of shim-signed:
 shim-signed depends on grub-efi-amd64-signed | grub-efi-arm64-signed; however:
  Package grub-efi-amd64-signed is not configured yet.
  Package grub-efi-arm64-signed is not installed.

dpkg: error processing package shim-signed (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 grub-efi-amd64
 grub-efi-amd64-signed
 shim-signed

I checked the file /usr/share/grub/grub-check-signatures and here is what is on line 22

    21          if ! [ -f $efivars/$secureboot_var ] \
    22                  || [ "$(od -An -t u1 $efivars/$secureboot_var | awk '{ print $NF }')" -ne 1 ]
    23          then
    24                  return 1
    25          fi

Not sure whats flipping my system. Would appreciate any help (would like to avoid OS reinstall if thats possible).



Solution 1:[1]

It looks like you didn't use sudo in installing packages. Try

$ sudo apt update
$ sudo apt install grub-efi-amd64

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Warriorjacq9