grub2-set-default

設置系統默認的啓動內核

語法

 1Usage: grub2-set-default [OPTION] MENU_ENTRY
 2Set the default boot menu entry for GRUB.
 3This requires setting GRUB_DEFAULT=saved in /etc/default/grub.
 4
 5  -h, --help              print this message and exit
 6  -v, --version           print the version information and exit
 7  --boot-directory=DIR    expect GRUB images under the directory DIR/grub2
 8                          instead of the /boot/grub2 directory
 9
10MENU_ENTRY is a number, a menu item title or a menu item identifier.
11
12Report bugs to <bug-grub@gnu.org>.

實例

查看可選的系統內核:

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

grub2-set-default後面的序號從0開始。所以,如果想設置第一個選項爲默認啓動內核,則可以使用下面的命令:

1# grub2-set-default 0

如果想使用CentOS Linux (3.10.0-862.el7.x86_64) 7 (Core)內核版本,則可以將0改爲2

重啓系統

1~]# init 6
2```[來源](https://github.com/jaywcjlove/linux-command):https://github.com/jaywcjlove/linux-command
最後修改於: Wednesday, January 31, 2024

相關文章:

翻譯: