
In this comprehensive guide, we will walk you through the process of setting the default Operating System (OS) in the GRUB bootloader using the terminal in Ubuntu 18.04. This is particularly useful if you have a dual-boot setup and want to specify which OS should be booted by default.
To set the default OS in GRUB using the terminal in Ubuntu 18.04, you can modify the GRUB configuration file located at /etc/default/grub
. Change the GRUB_DEFAULT
line to GRUB_DEFAULT=saved
to remember the last selected entry, and add GRUB_SAVEDEFAULT=true
to enable the feature that saves the last selected entry. Save the changes, update GRUB with sudo update-grub
, and reboot the system.
What is GRUB?
GRUB, which stands for Grand Unified Bootloader, is the default bootloader for most Linux distributions, including Ubuntu. It presents a menu from which you can choose which OS to boot if you have multiple OS installed on your system.
Accessing the GRUB Configuration File
The GRUB configuration file in Ubuntu is located at /etc/default/grub
. To edit this file, you will need to use a text editor with root privileges. In this guide, we will use the nano text editor.
Open a terminal by pressing Ctrl+Alt+T
and type the following command:
sudo nano /etc/default/grub
The sudo
command gives you root privileges, nano
is the text editor, and /etc/default/grub
is the path to the GRUB configuration file.
Modifying the GRUB Configuration File
In the GRUB configuration file, look for the line that starts with GRUB_DEFAULT=
. This line determines which entry in the GRUB menu is selected by default when the system boots. By default, it is set to 0
, which means the first entry in the GRUB menu is selected.
To set the default OS to the last one selected, change the line to:
GRUB_DEFAULT=saved
This tells GRUB to remember the last selected entry. Below the GRUB_DEFAULT
line, add the following line:
GRUB_SAVEDEFAULT=true
This enables the feature that saves the last selected entry.
Saving the Changes and Updating GRUB
After making the changes, save the file by pressing Ctrl+O
, then press Enter
. To exit the nano editor, press Ctrl+X
.
Next, you need to update the GRUB configuration to apply the changes. Run the following command:
sudo update-grub
This command generates a new GRUB configuration based on the changes you made to the /etc/default/grub
file.
Rebooting the System
Finally, reboot your system to apply the changes. The last selected OS will now be set as the default in the GRUB menu.
sudo reboot
Conclusion
By following these steps, you can easily set the default OS in the GRUB bootloader using the terminal in Ubuntu 18.04. This is especially useful in a dual-boot setup where you frequently use one OS more than the other.
For more advanced configuration options, you can refer to the GRUB documentation by running the info -f grub -n 'Simple configuration'
command in the terminal.
To open a terminal in Ubuntu 18.04, you can press Ctrl+Alt+T
on your keyboard. This will open a new terminal window.
The default bootloader in Ubuntu is GRUB, which stands for Grand Unified Bootloader. It is the default bootloader for most Linux distributions, including Ubuntu.
The GRUB configuration file in Ubuntu 18.04 is located at /etc/default/grub
. You can edit this file to modify the GRUB settings.
To edit the GRUB configuration file in Ubuntu 18.04, you can open a terminal and use a text editor with root privileges. For example, you can use the command sudo nano /etc/default/grub
to open the file with the nano text editor.
To set the default OS in GRUB using the terminal in Ubuntu 18.04, you need to modify the GRUB_DEFAULT
line in the /etc/default/grub
file. Change it to GRUB_DEFAULT=saved
to set the default OS as the last one selected. Additionally, add the line GRUB_SAVEDEFAULT=true
to enable the feature that saves the last selected entry. After making these changes, save the file and update GRUB using the command sudo update-grub
. Finally, reboot your system to apply the changes.
Yes, you can set a specific OS as the default in GRUB by modifying the GRUB_DEFAULT
line in the /etc/default/grub
file. Each OS in the GRUB menu has a numeric index. Set the value of GRUB_DEFAULT
to the index number of the desired OS. Remember that the index starts from 0 for the first entry.
After making changes to the /etc/default/grub
file, you need to update the GRUB configuration using the command sudo update-grub
. This command generates a new GRUB configuration based on the changes you made.
To reboot your system in Ubuntu, you can open a terminal and use the command sudo reboot
. This will initiate a system restart.