The βupdate-grub
β command, commonly used to apply changes made to the GRUB on Linux, was not available on my newly switched vanilla Arch system.
Initially, I was quite surprised because I remember selecting GRUB during installation, and the GRUB screen also appeared on system boot, but later I discovered the reason after switching to Ubuntu, where this command is available.
So, the reason for the unavailability of this command on Arch was that itβs not a standard Linux command like ls, cd, find, etc., whose binary files are available in the system directory. Of course, itβs a script file in the βsbin
β directory on Ubuntu, but itβs nothing more than an alias to the βgrub-mkconfig
β command.
$ sudo grub-mkconfig -o /boot/grub/grub.cfg
To solve this problem, you can either directly run the above command, but as you can see, itβs a long command to remember, so you can create a custom βupdate-grub
β command to run the same.
How to Solve βupdate-grub: command not foundβ Error on Linux
To resolve this issue, we will create the same βupdate-grub
β script file in the βsbin
β directory as in other Linux distributions, such as Ubuntu. So, open your terminal and execute the following command:
$ sudo nano /usr/sbin/update-grub
#OR
$ sudo vim /usr/sbin/update-grub
The above command will create a blank βupdate-grub
β file in the β/usr/sbin
β directory using your selected Nano or Vim editor. You can now copy and paste the following line into the script file above.
#! /bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"
To save the file, if youβre using Nano editor, press βCtrl+Oβ, hit βEnterβ, and then βCtrl+Xβ. If youβre using the Vim editor, enter in command-line mode and then type and enter the β!wqβ command.
Finally, change the file ownership to the root user using the chown command and assign read-write permission using the chmod command:
$ sudo chown root:root /usr/sbin/update-grub
$ sudo chmod 755 /usr/sbin/update-grub
Once done, βupdate-grub
β command will become accessible, and you can run it as a root user or with sudo privileges.
$ sudo update-grub
Output:
Thatβs it. I hope you find this article helpful. If youβre still stuck with the same error or have any queries related to the topic, do let me know in the comment section.
Till then, peace!
I wrote several times and it says that
/usr/sbin/update-grub: line 3: exec: grub-mkconfig: not found