# Don't run this as a script, run each command on its own and don't continue if any fail
# Make a directory to store the packages we'll be re-installing in
mkdir packages_to_install
cd packages_to_install
# Download the two packages that have configuration files in /etc/grub.d/
apt download grub-common
apt download memtest86+
# Rename /etc/grub.d/ as a reversible way to "delete" the files in /etc/grub.d/
sudo mv /etc/grub.d/ /etc/grub.d-backup/
# Re-install the packages passing --force-confmiss so that any missing configuration files (in this case everything in /etc/grub.d/ ) will be replaced with their defaults.
sudo dpkg --force-confmiss -i grub-common*.deb memtest*.deb
# After testing that everything is working fine, you can "rm -ri packages_to_install/" and "sudo rm -ri /etc/grub.d-backup/" to remove the clutter created in following these steps.