If we have access to the grub rescue, we can do the next steps:
grub rescue > ls
(hd0)... (hd0,gpt8)...
grub rescue > ls (hd2,gpt8) # try to recognize which partition is this
grub rescue > ls (hd2,gpt6) # let's assume this is the linux partition
grub rescue > set root=(hd2,gpt6)
grub rescue > set prefix=(hd2,gpt6)/boot/grub # or wherever grub is installed
grub rescue > insmod normal # if this produced an error, reset root and prefix to something else ..
grub rescue > normal
After these, you will get access to the grub, choose your linux system and get into. Once in your linux system, reinstall and reset the grub:
sudo grub-install
sudo grub-mkconfig -o /boot/grub/grub.cfg
That's all, now you can reboot your system if you want to test that grub is working.
The last part of code didn't work for me. So I used: