grub2-set-default

Set the system default startup kernel

grammar

Usage: grub2-set-default [OPTION] MENU_ENTRY
Set the default boot menu entry for GRUB.
This requires setting GRUB_DEFAULT=saved in /etc/default/grub.

   -h, --help print this message and exit
   -v, --version print the version information and exit
   --boot-directory=DIR expect GRUB images under the directory DIR/grub2
                           instead of the /boot/grub2 directory

MENU_ENTRY is a number, a menu item title or a menu item identifier.

Report bugs to <[email protected]>.

Example

View available system kernels:

# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (5.4.219-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1160.76.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-3221d376917c458992a952d6327f2d6a) 7 (Core)

The serial number after grub2-set-default starts from 0. So, if you want to set the first option to boot the kernel by default, you can use the following command:

# grub2-set-default 0

If you want to use CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core) kernel version, you can change 0 to 2

Restart the system

~]# init 6