grubby Command in Linux: Syntax, Options & Practical Examples

grubby Command in Linux: Syntax, Options & Practical Examples

The grubby command in Linux is used to view and modify kernel boot entries managed by the GRUB2 bootloader. System administrators commonly use it to change the default kernel, list installed kernels, and add or remove kernel boot parameters without manually editing GRUB configuration files. The utility is primarily available on RHEL-based distributions such as RHEL, Rocky Linux, AlmaLinux, and Fedora.


grubby Command Quick Reference Cheat Sheet

TaskCommand
List all installed kernelsgrubby --info=ALL
List kernel paths onlygrubby --info=ALL | grep ^kernel
Display details of a specific kernelgrubby --info="/boot/vmlinuz-$(uname -r)"
Get the default kernel pathgrubby --default-kernel
Get default kernel indexgrubby --default-index
Display default kernel titlegrubby --default-title
Set default kernel using pathgrubby --set-default=/boot/vmlinuz-$(uname -r)
Set default kernel using indexgrubby --set-default-index=1
Add kernel argument to default kernelgrubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="ipv6.disable=1"
Add kernel arguments to all kernelsgrubby --update-kernel=ALL --args="console=ttyS0"
Remove kernel argument from default kernelgrubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="quiet"
Remove kernel argument from all kernelsgrubby --update-kernel=ALL --remove-args="quiet"
Replace kernel argumentsgrubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="quiet" --args="console=ttyS0"
Add a new kernel entrygrubby --add-kernel=/boot/vmlinuz-new --initrd=/boot/initramfs-new.img --title="Custom Kernel"
Copy arguments from default kernelgrubby --add-kernel=/boot/vmlinuz-new --initrd=/boot/initramfs-new.img --copy-default
Remove kernel entrygrubby --remove-kernel=/boot/vmlinuz-old
Set root device for kernel entrygrubby --update-kernel=/boot/vmlinuz-$(uname -r) --root=/dev/sda1
Specify bootloader explicitlygrubby --grub2 --info=ALL
Display help for grubbygrubby --help

Understanding grubby in Linux

grubby command syntax

The basic syntax of the grubby command is:

bash
grubby [options]

The command is used to manipulate bootloader-specific configuration files, primarily for systems that use the GRUB2 bootloader. It allows administrators to list kernel entries, modify boot parameters, change the default kernel, and add or remove kernel arguments.

Common syntax examples include:

bash
grubby --info=ALL
grubby --default-kernel
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="kernel_args"

What the grubby command does

The grubby utility is designed to manage kernel boot entries without manually editing GRUB configuration files.

It provides functionality such as:

  • Listing installed kernel entries
  • Viewing kernel boot parameters
  • Changing the default kernel
  • Adding or removing kernel boot arguments
  • Adding or removing kernel entries

Instead of modifying files like /boot/grub2/grub.cfg directly, grubby updates the appropriate configuration files automatically.

How grubby works with GRUB2 bootloader

Modern Linux systems use the GRUB2 bootloader to manage kernel boot entries. Each installed kernel typically has its own configuration entry that contains:

  • Kernel path
  • Initial RAM disk (initrd)
  • Kernel boot arguments
  • Boot entry title

The grubby command modifies these entries safely by updating the boot configuration files associated with GRUB2.

This approach avoids manual editing of GRUB configuration files and reduces the risk of breaking the bootloader configuration.

Where kernel boot entries are stored

Kernel boot entries are stored in configuration files under the following directory:

bash
/boot/loader/entries/

Each file represents one kernel entry.

Example:

bash
ls /boot/loader/entries/

Example output:

bash
d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.el8.x86_64.conf
d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.1.2.el8_2.x86_64.conf

These files contain information about the kernel version, initramfs image, and kernel boot parameters.

Another important file used by GRUB2 is:

bash
/boot/grub2/grubenv

This file stores environment variables such as kernelopts, which contain default kernel arguments.

Supported Linux distributions for grubby

The grubby command is primarily available on RHEL-based Linux distributions. It is commonly used in enterprise environments where GRUB2 is the default bootloader.

Supported distributions include:

  • Red Hat Enterprise Linux (RHEL)
  • Rocky Linux
  • AlmaLinux
  • CentOS Stream
  • Fedora

Some Debian-based distributions do not include grubby by default because they manage boot entries differently.


List Installed Kernels

grubby list all kernels

To list all kernels configured in the bootloader, use:

bash
grubby --info=ALL

This command displays detailed information about every kernel entry available in the system's boot configuration.

Example output:

bash
index=0
kernel="/boot/vmlinuz-4.18.0-553.83.1.el8_10.x86_64"
args="ro console=tty0 console=ttyS0,115200n81 crashkernel=auto intremap=off edd=off nomodeset audit=1 audit_backlog_limit=8192"
root="UUID=22fdf631-6b15-4787-9143-1b7848c8e1b1"
initrd="/boot/initramfs-4.18.0-553.83.1.el8_10.x86_64.img"
title="Rocky Linux (4.18.0-553.83.1.el8_10.x86_64) 8.10 (Green Obsidian)"
id="f412309c04004990a89a8eed99f36e29-4.18.0-553.83.1.el8_10.x86_64"
index=1
kernel="/boot/vmlinuz-4.18.0-477.27.1.el8_8.x86_64"
args="ro console=tty0 console=ttyS0,115200n81 crashkernel=auto intremap=off edd=off nomodeset audit=1 audit_backlog_limit=8192"
root="UUID=22fdf631-6b15-4787-9143-1b7848c8e1b1"
initrd="/boot/initramfs-4.18.0-477.27.1.el8_8.x86_64.img"
title="Rocky Linux (4.18.0-477.27.1.el8_8.x86_64) 8.8 (Green Obsidian)"
id="f412309c04004990a89a8eed99f36e29-4.18.0-477.27.1.el8_8.x86_64"

Each entry corresponds to a kernel available in the GRUB boot menu.

This command displays information such as:

  • Kernel index
  • Kernel path
  • Kernel arguments
  • Root device
  • Initrd image
  • Boot entry title

Identify installed kernel paths

If you only want to list the kernel paths, you can filter the output.

Example:

bash
grubby --info=ALL | grep ^kernel

Example output:

bash
kernel="/boot/vmlinuz-4.18.0-425.el8.x86_64"
kernel="/boot/vmlinuz-4.18.0-372.el8.x86_64"

These paths represent the kernel binaries used during system boot.

Compare grubby output with uname -r

You can compare the list of installed kernels with the currently running kernel.

First check the running kernel:

bash
uname -r

Example output:

bash
4.18.0-425.el8.x86_64

Then compare it with the kernels listed by grubby:

bash
grubby --info=ALL | grep ^kernel

This helps verify whether the currently running kernel is the same as the default kernel configured for boot.


Get Information About Kernel Entries

grubby --info for specific kernel

You can display detailed information about a specific kernel entry using the --info option.

Example:

bash
grubby --info="/boot/vmlinuz-$(uname -r)"

Example output:

bash
index=1
kernel="/boot/vmlinuz-4.18.0-425.el8.x86_64"
args="ro quiet rhgb"
root="/dev/mapper/rhel-root"
initrd="/boot/initramfs-4.18.0-425.el8.x86_64.img"
title="Red Hat Enterprise Linux (4.18.0-425.el8.x86_64)"

This command is useful when you want to inspect the configuration of a specific kernel entry.

grubby --info=ALL explained

The --info=ALL option prints detailed information for every kernel entry available in the bootloader configuration.

Example:

bash
grubby --info=ALL

This command displays details such as:

  • Kernel index number
  • Kernel path
  • Boot arguments
  • Root device
  • Initrd image
  • Boot title

This is helpful when identifying which kernel entry should be modified.

Understand kernel arguments in boot entries

Kernel arguments define how the Linux kernel behaves during boot.

These parameters may include options for:

  • Debugging
  • Hardware configuration
  • Security settings
  • Network configuration

Example kernel arguments:

bash
quiet rhgb ipv6.disable=1 console=ttyS0

You can view the arguments for a kernel using:

bash
grubby --info="/boot/vmlinuz-$(uname -r)"

These parameters can later be modified using the --args or --remove-args options.


Find Default Kernel

grubby --default-kernel

The default kernel is the kernel version that the system will boot into after a restart. You can check the path of the default kernel using the --default-kernel option.

bash
grubby --default-kernel

Example output:

bash
/boot/vmlinuz-4.18.0-425.el8.x86_64

This shows the kernel image that GRUB2 will use during the next system boot.

grubby --default-index

Each kernel entry in GRUB2 has an index number. You can retrieve the index of the default kernel using:

bash
grubby --default-index

Example output:

bash
1

This means the kernel entry with index 1 is currently set as the default boot kernel.

To see the mapping between index and kernel path:

bash
grubby --info=ALL | grep -E "^index|^kernel"

grubby --default-title

You can also display the title of the default kernel entry shown in the GRUB boot menu.

bash
grubby --default-title

Example output:

bash
Red Hat Enterprise Linux (4.18.0-425.el8.x86_64)

This title appears in the GRUB2 menu during system startup.

Verify default kernel before reboot

Before rebooting the system, it is recommended to verify the current default kernel.

Check the kernel configured for boot:

bash
grubby --default-kernel

Check the currently running kernel:

bash
uname -r

If the two values differ, the system will boot into a different kernel version after reboot.


Change Default Kernel

Set default kernel using kernel path

You can change the default kernel by specifying the kernel path using the --set-default option.

Example:

bash
grubby --set-default=/boot/vmlinuz-4.18.0-372.el8.x86_64

Example output:

bash
The default is /boot/loader/entries/xxxxxxxx-4.18.0-372.el8.x86_64.conf

This sets the specified kernel as the default boot entry.

Set default kernel using index number

Instead of providing the kernel path, you can also change the default kernel using the index number.

First list kernel entries with their indexes:

bash
grubby --info=ALL | grep -E "^index|^kernel"

Example output:

bash
index=0
kernel="/boot/vmlinuz-4.18.0-425.el8.x86_64"
index=1
kernel="/boot/vmlinuz-4.18.0-372.el8.x86_64"

Then set the default kernel using the index value:

bash
grubby --set-default-index=1

Verify default kernel change

After modifying the default kernel, confirm the change using:

bash
grubby --default-kernel

Example output:

bash
/boot/vmlinuz-4.18.0-372.el8.x86_64

This ensures the correct kernel will be used during the next reboot.


Add Kernel Arguments

grubby add args to default kernel

Kernel arguments allow you to control how the Linux kernel behaves during boot. You can add arguments to the default kernel using the --update-kernel option.

Example:

bash
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="ipv6.disable=1"

This command disables IPv6 by adding the ipv6.disable=1 parameter.

grubby --update-kernel with arguments

The --update-kernel option modifies an existing kernel entry.

Example:

bash
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="console=ttyS0"

This adds the console logging parameter to the kernel boot arguments.

You can verify the change using:

bash
grubby --info="/boot/vmlinuz-$(uname -r)"

Add kernel parameters to all kernels

If you want to apply a kernel parameter to all installed kernels, use ALL instead of specifying a kernel path.

Example:

bash
grubby --update-kernel=ALL --args="audit=1"

This command enables kernel auditing for all kernel entries.


Remove Kernel Arguments

grubby remove args from kernel

If a kernel argument is no longer required, it can be removed using the --remove-args option.

Example:

bash
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="ipv6.disable=1"

This removes the previously added IPv6 disabling parameter.

Remove kernel parameters safely

Before removing kernel arguments, it is recommended to inspect the current kernel configuration.

Check existing kernel parameters:

bash
grubby --info="/boot/vmlinuz-$(uname -r)"

After confirming the parameters, remove them using --remove-args.

Example:

bash
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="quiet"

Remove arguments from all kernels

To remove a kernel argument from every kernel entry, use the ALL option.

Example:

bash
grubby --update-kernel=ALL --remove-args="quiet"

This removes the quiet parameter from all installed kernel boot entries.


Update Kernel Boot Entry

grubby --update-kernel explained

The --update-kernel option is used to modify an existing kernel boot entry. It allows administrators to update kernel parameters without manually editing GRUB configuration files.

Example:

bash
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="audit=1"

This command updates the boot entry of the currently running kernel and adds the audit=1 parameter.

You can also apply updates to all kernels using:

bash
grubby --update-kernel=ALL --args="audit=1"

Modify existing kernel boot parameters

Kernel boot parameters define how the Linux kernel behaves during system startup. Using grubby, you can modify these parameters directly.

Example:

bash
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="console=ttyS0"

This adds the console=ttyS0 parameter to enable serial console logging.

To verify the modification:

bash
grubby --info="/boot/vmlinuz-$(uname -r)"

This command displays the updated kernel arguments.

Update kernel arguments without editing GRUB

Traditionally, kernel parameters were edited in GRUB configuration files such as:

text
/etc/default/grub

However, editing these files requires rebuilding the GRUB configuration using commands like grub2-mkconfig.

The grubby utility simplifies this process by updating the boot entry configuration files directly, eliminating the need to regenerate the entire GRUB configuration.

Example:

bash
grubby --update-kernel=ALL --remove-args="quiet"

This removes the quiet parameter from all kernel entries without modifying GRUB configuration files manually.


Add New Kernel Entry

grubby add kernel entry

You can add a new kernel entry manually using the --add-kernel option. This is useful when testing custom kernels or adding manually compiled kernels.

Example:

bash
grubby --add-kernel=/boot/vmlinuz-custom --initrd=/boot/initramfs-custom.img --title="Custom Kernel"

This creates a new boot entry that will appear in the GRUB boot menu.

Copy arguments from existing kernel

If you want the new kernel entry to inherit parameters from the current default kernel, use the --copy-default option.

Example:

bash
grubby --add-kernel=/boot/vmlinuz-custom --initrd=/boot/initramfs-custom.img --title="Custom Kernel" --copy-default

This copies all kernel arguments from the default kernel entry.

Add custom kernel boot entry

You can also specify custom kernel parameters when adding a new entry.

Example:

bash
grubby --add-kernel=/boot/vmlinuz-custom --initrd=/boot/initramfs-custom.img --title="Debug Kernel" --args="console=ttyS0 debug"

This creates a new boot entry with debugging parameters.

After creating the entry, verify it using:

bash
grubby --info=ALL

Remove Kernel Entry

WARNING
Use this command with caution as it will remove the boot entry of the provided kernel. If you remove kernel entry of incorrect kernel, your system may fail to boot and then you will have to boot into single user mode to fix your broken server

grubby remove kernel entry

If a kernel entry is no longer required, it can be removed using the --remove-kernel option.

Example:

bash
grubby --remove-kernel=/boot/vmlinuz-4.18.0-372.el8.x86_64

This removes the specified kernel entry from the bootloader configuration.

Identify kernel before removal

Before removing a kernel entry, it is recommended to verify which kernels are installed.

Example:

bash
grubby --info=ALL | grep ^kernel

Example output:

bash
kernel="/boot/vmlinuz-4.18.0-425.el8.x86_64"
kernel="/boot/vmlinuz-4.18.0-372.el8.x86_64"

This helps ensure that the correct kernel entry is selected for removal.

Safely remove unused kernels

Removing unused kernels helps maintain a clean system and reduces boot menu clutter.

Example:

bash
grubby --remove-kernel=/boot/vmlinuz-old-kernel

After removal, verify the remaining kernel entries:

bash
grubby --info=ALL

Always ensure that at least one working kernel remains installed to prevent boot failures.


grubby vs grub2-editenv

When to use grubby

The grubby command is used to modify kernel boot entries and kernel parameters. It is ideal for tasks such as:

  • Changing the default kernel
  • Adding or removing kernel arguments
  • Viewing kernel boot entries
  • Managing multiple kernel configurations

It directly updates kernel entry files used by GRUB2.

When to use grub2-editenv

The grub2-editenv command manages GRUB environment variables stored in the file:

bash
/boot/grub2/grubenv

This tool is commonly used to:

  • Set GRUB environment variables
  • Modify saved boot entries
  • Configure boot options dynamically

Example:

bash
grub2-editenv list

This displays the environment variables stored in the GRUB environment file.

Differences in kernel configuration tools

Both tools interact with the GRUB bootloader but serve different purposes.

ToolPurpose
grubbyModify kernel boot entries and arguments
grub2-editenvManage GRUB environment variables

In most cases, administrators use grubby for kernel management and grub2-editenv for managing GRUB environment settings.


Frequently Asked Questions

1. What is the grubby command in Linux?

The grubby command is a Linux utility used to view and modify kernel boot entries and arguments in GRUB2 bootloader configuration.

2. How do I list installed kernels using grubby?

You can list installed kernels using the command grubby --info=ALL which displays all kernel entries available in the bootloader configuration.

3. How do I change the default kernel using grubby?

You can change the default kernel using grubby --set-default followed by the kernel path or by using grubby --set-default-index with the kernel index number.

4. What Linux distributions support grubby?

The grubby utility is commonly available on RHEL, Rocky Linux, AlmaLinux, CentOS Stream, and Fedora systems that use GRUB2 bootloader.

Summary

The grubby command is a powerful Linux utility used to manage kernel boot entries in systems that use the GRUB2 bootloader. It allows administrators to list installed kernels, view kernel configuration details, change the default boot kernel, and add or remove kernel boot parameters without manually editing GRUB configuration files.

In this guide, we explored practical scenarios such as listing installed kernels, retrieving kernel entry information, changing the default kernel, and modifying kernel boot arguments. Using grubby simplifies kernel management tasks and helps ensure boot configuration changes are applied safely across multiple kernel entries.

Understanding how to use grubby is particularly useful for system administrators working with RHEL-based distributions, where managing kernel parameters and boot entries is a common task during troubleshooting, performance tuning, and system maintenance.


Official Documentation

For a complete list of options and advanced usage details, refer to the official grubby manual page:

grubby command man page

Deepak Prasad

Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, networking, and security, delivering robust and efficient solutions for diverse projects.