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.