Fixing the ‘update-grub: command not found’ Error in Linux

Linux TLDR
Last Updated:
Reading time: 2 minutes

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.

update-grub command not found

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:

running the update-grub command

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!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.