grub2-mkconfig: command not found

The grub2-mkconfig command generates a new grub.cfg configuration file, and is used to update an existing grub.cfg file. The grub2-mkconfig command combines the configuration file templates in the /etc/grub.d/ directory with the settings in /etc/default/grub to generate the grub.cfg configuration file.

Note: On some distributions, this command is simply grub-mkconfig.

Syntax

The syntax of the grub2-mkconfig command is:

# grub2-mkconfig [-o {file name}]

If you encounter the below error while running the grub2-mkconfig:

grub2-mkconfig: command not found

You may install the below package:

# dnf install grub2-tools-1

Rebuilding Your GRUB Configuration File

Whenever you change your GRUB configuration, you need to rebuild it. Follow the steps outlined below:

1. The command to rebuild your GRUB configuration varies. On Fedora and openSUSE, use this command:

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Some distros, such as Ubuntu, use:

$ sudo grub-mkconfig -o /boot/grub/grub.cfg

2. Ubuntu Linux also has a script that runs grub-mkconfig, update-grub:

$ sudo update-grub
Related Post