When you turn on an Ubuntu Linux computer, the very first piece of software that runs is GRUB (the Grand Unified Bootloader). GRUB is responsible for loading the Linux kernel into memory. If you want to configure your computer to “dual-boot” with Windows, or if you want to change the default operating system that boots when you press the power button, you must edit the GRUB configuration file.
However, editing the GRUB bootloader is incredibly dangerous. If you make a typo in this file, your computer will literally refuse to turn on, leaving you staring at a black screen. Before you attempt any modifications, you must safely extract and back up the exact, working configuration file.
How to Safely Extract the Ubuntu GRUB Bootloader Configuration
You must copy the core GRUB configuration script out of the `/etc/default` directory.
- Open your Terminal application (Ctrl + Alt + T).
- The master configuration file that controls how GRUB behaves is located at
/etc/default/grub. You cannot copy this file using a normal file manager because it is owned by the root system administrator. - To safely extract the file and place a perfect copy on your Desktop, type the following command and press Enter:
sudo cp /etc/default/grub ~/Desktop/grub_backup.txt - Type your administrator password when prompted (the characters will remain invisible).
You now have a safe, offline backup of your working bootloader configuration sitting on your Desktop. You can open grub_backup.txt in a text editor to study it. If you ever completely break your computer’s boot sequence in the future, you can boot from an Ubuntu Live USB drive, open the terminal, and overwrite the broken system file with your perfect backup copy (e.g., sudo cp /path/to/grub_backup.txt /etc/default/grub), instantly fixing the computer.