Ubuntu and most other Linux distributions now use the GRUB2 boot loader. You can change its settings to select a default operating system, set a background image, and choose how long GRUB counts down before automatically booting the default OS.
We configured GRUB2 on Ubuntu 24.04.1 here, but the process should be similar for other Linux distributions. You may have customized the original GRUB’s settings by editing its menu.lst file in the past, but the process is now different.
GRUB2 Configuration Basics
GRUB2 doesn’t use a menu.lst file. Instead, its main configuration file is the /boot/grub/grub.cfg file. However, you shouldn’t edit this file by hand! This file is just for GRUB2’s own usage. It’s automatically created by running the update-grub or grub2-mkconfig command as root—in other words, by running sudo update-grub on Ubuntu.
Your own GRUB settings are stored in the /etc/default/grub file. Edit this file to change GRUB2’s settings. Scripts are also located in the /etc/grub.d/ directory. For example, on Ubuntu, there are scripts here that configure the default theme. There’s also an os-prober script that checks the system’s internal hard drives for other installed operating systems—Windows, other Linux distributions, Mac OS X, and so on—and automatically adds them to GRUB2’s menu.
When you run the update-grub command, GRUB automatically combines the settings from the /etc/default/grub file, the scripts from the /etc/grub.d/ directory, and everything else, creating a /boot/grub/grub.cfg file that’s read at boot.
In other words, to customize your GRUB2 settings, you’ll have to edit the /etc/default/grub file and then run the sudo update-grub command, or, on Fedora Linux, the sudo grub2-mkconfig command.
Edit the GRUB Configuration File
Open the /etc/default/grub file for editing in a standard text editor. If you want to use a graphical text editor, open a terminal and run the following command:
gnome-text-editor /etc/default/grub
Alternatively, on older versions of Ubuntu, you can use this command:
gedit /etc/default/grub
For an easy-to-use terminal-based editor, Nano, use the following command. You can use any text editor you like, of course, including the standard vi text editor.
sudo nano /etc/default/grub
The /etc/default/grub file is short and should be easy to edit. As with any other configuration file, you need to edit the options to your desired state and then change the file. If any of the options below doesn’t already appear in the file, add it on a new line. If it does, edit the existing line instead of adding a duplicate one.
Choose the Default OS
To make a different operating system installed on your system the default, change the GRUB_DEFAULT= line. GRUB_DEFAULT=0 uses the first entry as the default. Change the number to 1 to use the second entry, 2 to use the third entry, or so on.
You could also use GRUB_DEFAULT=saved and GRUB would automatically boot the last operating system you chose each time you boot. You can also specify a label in quotes. For example, if you had an operating system named Windows Boot Manager in your OS list, you could use GRUB_DEFAULT=”Windows Boot Manager”
Save a Default Operating System
If you choose GRUB_DEFAULT=saved, you also need to add a GRUB_SAVEDEFAULT=true line. Otherwise, it won’t work.
Choose Whether GRUB is Hidden
With only one operating system installed, Ubuntu defaults GRUB to automatically boot to the default OS with the GRUB_HIDDEN_TIMEOUT=0 option. This option specifies GRUB will be hidden and it will automatically boot to the default OS after 0 seconds—immediately, in other words. You can still access the menu by holding Shift as your computer boots.
To set a higher timeout, use something like:
GRUB_HIDDEN_TIMEOUT=5
GRUB will display an empty screen or splash screen for five seconds, during which you can press any key to view the menu. To prevent GRUB from being automatically hidden, comment the line out—just add a # before it so that it reads:
#GRUB_HIDDEN_TIMEOUT=0
If GRUB isn’t automatically hidden, you’ll see the menu each time your computer boots. GRUB will automatically boot the default operating system after a period of time, usually ten seconds. During that time, you can choose another OS or leave it be to boot automatically.
To change the timeout period, edit the GRUB_TIMEOUT=10 line and enter any number of seconds you like. (Remember, this is only used if GRUB isn’t hidden.) To prevent GRUB from booting automatically and always wait for you to choose an OS, change the line to:
GRUB_TIMEOUT=-1
Choose a Background Image
The GRUB_BACKGROUND line controls whether a background image is used. By default, GRUB uses a white-on-black monochrome look. You can add a line like GRUB_BACKGROUND=”/home/user/Pictures/background.png” to specify an image file GRUB will use.
GRUB supports JPG/JPEG, PNG, and TGA image files. In the past, we warned against using JPG files because they were limited to 256 colors. However, in our testing and research, this appears to no longer be the case, so you can use any format you want.
Make Your Changes Take Effect
To have your changes take effect, simply save the text file using Hamburger Menu > Save in GNOME Text Editor or Ctrl+O and then Enter to save the file in Nano—and then run the sudo update-grub command. If you’re using Fedora Linux, instead use the sudo grub2-mkconfig command. Your changes will become part of the grub.cfg file and will be used each time you boot your computer.
These aren’t all of GRUB’s settings, but they are some of the most commonly changed. Other settings can be customized in the /etc/default/grub file, or by editing the scripts in the /etc/grub.d directory.
If you don’t want to edit the files by hand, you may be able to find graphical tools for customizing GRUB2 in your Linux distribution’s software repositories. The above method should work even on Linux distros where such tools aren’t easily available, or if you just have command-line access and want to do it by hand.