GRUB Rescue - setting boot and prefix again and again

I got a solution for this type of problem if grub rescue> prompt occurs in booting time and you have to write a code like:

grub rescue> ls
grub rescue> set boot=(hd0,msdos*)
grub rescue> set prefix=(hd0,msdos*)/boot/grub
grub rescue> insmod normal
grub rescue> normal

After boot Linux/Ubuntu based OS will load then open a terminal and write the command:

useranf@ ~ $ sudo update-grub

then type this command:

useranf@ ~ $ sudo grub-install /dev/sda

after these operation now finally reboot your system.