How to Use GRUB Rescue on Ubuntu 18.04, 20.04 and 22.04

GRUB is a bootloader software. It is widely used as the default bootloader for Linux. Although GRUB is used widely in Linux, GRUB can also boot Windows operating systems as well. It is very powerful and extensible.

GRUB bootloader has powerful command line interface that can be used to solve boot problems. It’s called GRUB Rescue.

In this article, I will show you how to use GRUB Rescue command line interface of GRUB. I am using Ubuntu 18.04 LTS for the demonstration. Let’s get started.

Getting into the GRUB Rescue Command Line Interface:

By default, if everything is alright, when you start your computer, you should be booted right into the operating system you’ve installed. In my case, it is the Ubuntu 18.04 LTS operating system.

If anything goes wrong and it causes boot problems, then you most probably will see the GRUB rescue command line interface. It looks something like the screenshot given below.

At times, you will be able to see the GRUB menu as in the screenshot below. To go to the GRUB Rescue from here, press c.

You should be able to go to the GRUB Rescue command line mode as you can see from the screenshot below.

In the next section I will show you how to use GRUB Rescue. First, I will show you how to boot into Ubuntu 18.04 LTS operating system that I have installed. Then I will discuss some of the common GRUB Rescue commands.

Using GRUB Rescue to Boot into Ubuntu 18.04 LTS:

In the GRUB Rescue command line interface, you can list the hard drives and partitions you have installed with the following command:

grub> ls

As you can see, I have (hd0), (hd0, gpt1) and (hd0,gpt2) available. (hd0) represents the raw hard drive. (hd0,gpt1) and (hd0,gpt2) are the first and second GPT partitions of (hd0) respectively.

I’ve Ubuntu 18.04 LTS installed on UEFI hardware. So the first partition (hd0,gpt1) is the EFI partition and the second partition (hd0,gpt2) is the root partition. The files required to boot into the operating system is in the /boot directory of (hd0,gpt2) partition in my case. You may have /boot directory in a separate partition, in that case, make changes to the commands as you see fit.

You can list what files you have in a certain partition with ls command from the GRUB Rescue command line interface.

List the files and directories of the root partition (hd0,gpt2) with the following command:

grub> ls (hd0,gpt2)/

As you can see, the files and directories are listed.

We are interested in the files we have in the /boot directories.

grub> ls (hd0,gpt2)/boot

You should find two files in the /boot directory, vmlinuz and initrd as marked in the screenshot below. These files are required in order to boot correctly.

Now set the root variable to point to the root partition (hd0,gpt2) with the following command:

grub> set root=(hd0,gpt2)

Now you have to use the linux command to make the relative path of vmlinuz file known to GRUB bootloader.

You can do that with the following command:

grub> linux /boot/vmlinuz-4.15.0-20-generic root=/dev/sda2

NOTE: Here root=/dev/sda2 is required. Otherwise you may not be able to boot. /dev/sda2 means, that it is the second partition of the first hard drive. I added a table to help you understand how it works.

GRUB Identifier Hard Drive Partition Linux Identifier
(hd0) First /dev/sda
(hd0,gpt1) First First /dev/sda1
(hd0,gpt2) First Second /dev/sda2
(hd1) Second /dev/sdb
(hd1,gpt2) Second Second /dev/sdb2
(hd1,gpt5) Second Fifth /dev/sdb5

Also know that file and directory auto completion with the <Tab> key works in the GRUB command line interface as well, just like it does in a Linux terminal. So you should not have hard time navigating around GRUB command line interface.

Now you have to run the initrd command to make the initrd image know to the GRUB bootloader.

You can do that with the following command:

grub> initrd /boot/initrd.img-4.15.0-20-generic

Now that everything is set, you can run the following GRUB command to boot into your Ubuntu 18.04 LTS operating system.

grub> boot

The boot process should start as you can see from the screenshot below.

You should see the login screen afterward. Login to your Ubuntu 18.04 LTS system.

Now that you’re logged in, run the following command to update the GRUB 2 configuration file:

$ sudo update-grub2

The GRUB 2 configuration should be updated.

You may also need to re-install GRUB bootloader with the following command:

$ sudo grub-install /dev/sda

NOTE: Here /dev/sda is the hard drive where you want to install GRUB bootloader. Usually, it is the hard drive where you have your root partition.

Now that everything is working, you should be able to boot normally. If you still need something fixed, you can do it right now.

Loading Additional Modules:

At times, the GRUB command line interface prompt should be grub rescue> instead of


In that case, you need to run 2 additional commands. They are used to load GRUB modules that are not loaded by default. But are very important to boot the system.

The commands are:

grub rescue> insmod normal
grub rescue> insmod linux
Useful GRUB Rescue Commands:

In this section, I am going to list some of the common GRUB rescue commands that you may need in order to troubleshoot boot problems.

set pager=1 – If the output of any command is long enough that it doesn’t fit the screen, then this commands shows the outputs in a pager, like less in Linux terminal.

lsmod – It lists all the GRUB modules that are loaded.

cat – used to read files.

usb – list all the USB devices attached to your system.

clear – clears all the text from the GRUB command line window.

configfile grub.cfg_filePath – You can add a grub.cfg file using this command.

insmod – load GRUB module.

lspci – list all the attached PCI devices.

ls – list files, directories and block devices of your computer.

Although, this article is geared toward Ubuntu 18.04 LTS, it should work for any other modern Linux distribution that uses GRUB bootloader. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.