1. 查看启动菜单
egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \’
menuentry 'CentOS Linux (4.11.8-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-c376c392-8e32-46c8-9496-cd004fb61679' {
menuentry 'CentOS Linux (0-rescue-c2a4bfa7e0c74436b3a978656ab959e8) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-c2a4bfa7e0c74436b3a978656ab959e8-advanced-c376c392-8e32-46c8-9496-cd004fb61679' {
2. 设置默认菜单为第1项
grub2-set-default 0
3. 修改超时时间为 1秒
sed -i -r "s/set timeout=[0-9]+/set timeout=1/g" /boot/grub2/grub.cfg
4. 确认 /boot/grub2/grub.cfg 修改成功
grep timeout /boot/grub2/grub.cfg
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=1
# Fallback normal timeout code in case the timeout_style feature is
set timeout=1