It seems annoying that when you boot into Ubuntu on a Mac it takes over and becomes the default OS, even if something else (e.g. macOS or Boot Camp Windows) was previously the default.
The only way I have found to get back macOS as the default boot OS is to fully boot back into macOS (using Alt/Option on boot to select it), and then manually set macOS back to being the default using 'System Preferences/Startup Disk', which seems a bit excessive.
I'm actually going to post my own command line answer which I've worked out.
But I am also genuinely very happy to hear and up-vote any other command line or GUI-based answers which can set macOS back to being the default from within Ubuntu. (Or can prevent Ubuntu from taking over as the default in the first place!)
42 Answers
On the lastest version of Ubuntu (20.04) and on current versions of macOS (Catalina or Big Sur) this works to reset to macOS and stay reset:
As a one-time step, add this line to your Ubuntu .bashrc file:
alias osx='sudo efibootmgr -o 80,0 && reboot'From then on, when you want to reboot into macOS, open a terminal in Ubuntu if you haven't got one open already.
Type osx and press return.
Enter your password if required.
This should reboot you back into macOS. If you have more than one macOS, it will reboot back into whatever was the previously selected macOS default. It is 'sticky' (macOS stays set back as the default).
There is no equivalent way back from macOS to Ubuntu; reboot while holding down Alt/Option as normal. But that is okay because Ubuntu stays selected once you've chosen it; unlike macOS without this method. 🙂
[Worked out after a fair bit of research, with the help of efibootmgr in Ubuntu and bootoption in macOS!]
When Ubuntu is installed, a EFI/BOOT/BOOTX64.EFI file is place on the first EFI partition. This is the file that can be selected to boot from the Mac Startup Manager. Also, the GRUB file EFI/ubuntu/grubx64.efi and secure boot file EFI/ubuntu/shimx64.efi are both placed in the first EFI partition. Having the firmware boot either of these two files will result in the booting of Ubuntu. The difference on a Mac is that the booting of EFI/ubuntu/shimx64.efi will result on configuring the Mac to always boot Ubuntu. Since EFI/BOOT/BOOTX64.EFI and EFI/ubuntu/shimx64.efi files are identical, using the Mac Startup Manger to boot Ubuntu will result in Ubuntu becoming the default.
Below are possible ways to avoid Ubuntu becoming the default.
- Copy
EFI/ubuntu/grubx64.efitoEFI/BOOT/BOOTX64.EFI. The problem with this solution is that an update to Ubuntu may undo this change. - Create a new EFI (or possibly a FAT or ExFAT partition) and install a UEFI shell. Configure this shell to boot
EFI/BOOT/BOOTX64.EFI. This will result in a new item appearing in the Mac Startup Manager. You can change the icon and label of this item to distinguish this item from the other choices. - Create a new EFI (or possibly a FAT or ExFAT partition) and install rEFInd. Configure rEFInd to silently instruct the firmware to boot
EFI/BOOT/BOOTX64.EFI. This will result in a new item appearing in the Mac Startup Manager. You can change the icon and label of this item to distinguish this item from the other choices. Although you may wish to use rEFInd as the default startup manager instead of the built‑in one.