When booting to the graphical desktop fails we sometimes are recommended to boot into a "root shell" or to boot in "recovery mode".
How do I do that?
During boot press and hold the left Shift key or any other key. This will bring up the Grub2 menu from where we can select "Advanced options for Ubuntu".
After that we will be able to select the kernel we wish to boot in "Recovery mode":
This will lead us to the advanced options. By selecting "Enable networking" we gain access to our network and the internet for upgrades or downloads, and we will also mount our hard drives in read/write mode in case we need to edit files.
After the network has loaded, and fielsystems were mounted we will be presented again with the menu, from where we can choose "Drop to a root shell propmpt":
Note that we are root in this shell. Hence no sudo is needed for administrative tasks. This also means we have full access to all files, and we may cause irreversible damage to our system if we made a mistake.
If we had not enabled read/write access with "Enable networking" the filesystem will be mounted read only, and we are unable to edit files.
In case we don't have access to a network, or this was not desired, we can remount our filesystem(s) giving write access with the following command:
mount -o rw,remount /
From the root shell type
exit to go back to the menu.
During the boot process of the computer we press and hold the left Shift key. This will bring up the Grub2 boot menu from where we can select "recovery mode" (usually the second boot entry).
This will lead to the Grub2 recovery menu:
"Drop to root shell prompt" gives you a command line root environment from where you can access your files as root (no
sudo required). After having done your work on your files you can leave the command line shell by
Choose "Resume normal boot" to proceed booting as usual.
Note: see this question for a solution when the Grub recovery menu does not load the shell.
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?