I found online that a convenient way of updating grub2 without knowing the rather long command is to create a shorter alias to it. The command to update grub2 is
Code:
grub2-mkconfig -o /boot/grub2/grub.cfg
To make a global alias that is persistent after reboot, you can do this:
as root, open up /etc/bashrc like so
Then, go to the end of the file and insert this line:
Code:
alias update-grub='grub2-mkconfig -o /boot/grub2/grub.cfg'
In theory, this change should be persistent after reboot and you should now be able to update grub by running update-grub as root or via sudo if you are in the sudoers file. However, this did NOT work for me, so this is what I did:
I created a file in /sbin called update-grub. I used vi but you can use whatever editor you want. Then I coded the file like so:
Code:
#!/bin/bash
# Custom file written to update grub - kpt
grub2-mkconfig -o /boot/grub2/grub.cfg
Then, I just did a chmod 750 on the file. Since /sbin is in root's path, I can invoke the command just by doing
I don't know why the alias trick didn't work, but this one definitely does.