How to check if Ubuntu has booted in UEFI mode?
You can use the following command line,
test -d /sys/firmware/efi && echo efi || echo bios
or longer but easier to understand
if test -d /sys/firmware/efi;then echo efi;else echo bios;fi
See the following link,
help.ubuntu.com/community/Installation/FromUSBStick#Test_if_running_in_UEFI_mode
Edit: Comment about /boot/efi
/boot/efi
is a persistent directory (that survives shutdown and reboot), while /sys/firmware/efi
, actually the content of the /sys
file system is created every time the computer is booted.
The existence of /boot/efi
, a directory in an EFI system partition, can make it possible to boot in UEFI mode, but it does not make it impossible to boot in BIOS mode. So it does not tell you in which mode the computer is booted. It is possible to have installed Ubuntu and other linux systems that can boot both in UEFI and BIOS mode.
The easiest way to find out if you are running UEFI or BIOS is to look for a folder /sys/firmware/efi
.
The folder will be missing if your system is using BIOS.
Execute:
$ ls /sys/firmware/efi
Example of UEFI boot output :