When you modify the grub system configuration file “/etc/default/grub”, these changes are not automatically saved into the grub package but you need to update the grub to save these changes. The grub command changes the system’s boot settings, like the boot time.
Sometimes, updating the grub command, we encounter the grub command not found error, which prevents systematic changes to the grub config file. This guide will discuss this error and its solutions with this timeline:
- Reason: grub Command is Missing
- Solution 1: Use the Required Libraries to Update grub Command
- Solution 2: Add the Command Manually to System $Path
Let’s start the solution for this update-grub command error.
Reason: grub Command is Missing
If you receive the error “update-grub: command not found” on a Linux system, the update-grub command is unavailable on your system. This could be because the package that provides this command is not installed or the command is not in your system’s PATH. If both solutions did not work, you could reinstall the grub in the system.
Solution 1: Use the Required Libraries to Update grub Command
The grub update command is used to update the changes for the grub configuration file within the grub package. The update command is present within the grub-mkconfig file; the below command can update the grub:
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
In some Linux distributions, the grub2 is installed, where the below grub command will be utilized:
$ sudo grub2-mkconfig -o /boot/grub/grub.cfg
Now, run the update-grub command, which will work perfectly using the below command:
$ sudo update-grub
The update-grub command not found error is fixed successfully.
Solution 2: Add the Command Manually to System $Path
Update-grub is a system file, and its default location is “/usr/sbin/update-grub”. We can add the update-grub command mkconfig shell script in the default file to remove this error using the following steps:
The default “/usr/sbin/update-grub” file can be edited in the nano editor by running the following command:
$ sudo nano /usr/sbin/update-grub
Add the below bash shell script in the “/usr/sbin/update-grub” file:
#!/bin/sh set -e exec grub-mkconfig -o /boot/grub/grub.cfg "[email protected]"
Press the “Ctrl + O” to save the changes, then hit the “Enter” key and press “Ctrl + X” to exit.
Now, run the below command to provide the execute permissions for the bash shell script to all the users in the system:
$ sudo chmod 777 /usr/sbin/update-grub
Now, we can update the grub command using the below code:
$ sudo update-grub
The update-grub command not found error is fixed.
These are all the reasons and solutions to the update-grub command error.
The update-grub command in Linux is used to update the changes for the grub configuration files to the system grub package. You can resolve the “update grub command not found” error by running the “grub-mkconfig” command or adding the grub-mkconfig $Path to grub default file “/usr/sbin/update-grub”.