UEFI Shell

On this page 7

The UEFI Shell is a command-line environment that runs inside UEFI firmware, before any operating system is loaded. It lets an administrator browse file systems, inspect devices and memory, edit firmware variables, run EFI applications and execute scripts, all in the pre-boot environment. In the Boot & firmware stage of operating systems, it plays the role that a recovery console or terminal plays after boot.

The shell is itself an EFI application, usually a file named Shell.efi or BOOTX64.EFI, defined by the UEFI Shell Specification and implemented in the open-source TianoCore EDK II project. Some motherboards embed it in firmware, while others require it to be launched from a USB drive or the EFI system partition.

How the UEFI Shell runs in the pre-boot environment

The UEFI Shell runs as a regular UEFI application on top of Boot Services, the firmware interfaces available before an operating system calls ExitBootServices(). It uses firmware protocols for console input and output, block devices, the simple file system and the network, so it needs no drivers of its own for hardware that the firmware already supports.

At startup the shell builds a mapping table that assigns names to devices: fs0:, fs1: for FAT-formatted file systems the firmware can read, and blk0:, blk1: for raw block devices. Commands then address files with paths such as fs0:\EFI\BOOT. If a file named startup.nsh exists on a mapped file system, the shell runs it automatically after a short countdown, usually five seconds.

The table below lists the shell concepts that differ most from an ordinary operating system terminal.

ConceptMeaningExample
MappingShort name for a device or file systemfs0:, blk2:
Startup scriptScript run automatically at shell launchstartup.nsh
Script fileBatch file with the .nsh extensionupdate.nsh
EFI applicationExecutable in PE/COFF formatbootmgfw.efi, grubx64.efi
Device handleFirmware object representing a deviceListed by the dh command
UEFI variablePersistent setting stored in NVRAMBootOrder, Boot0001
Core concepts of the UEFI Shell

Essential UEFI Shell commands

UEFI Shell commands combine familiar file operations with firmware-specific tools. File commands resemble those of DOS and Unix, while others expose information that is normally hidden from the user, such as driver bindings and boot variables.

The following table groups the commands that administrators use most often.

CommandPurposeTypical use
map -rRebuilds device mappingsDetect a newly inserted USB drive
ls, cd, cpBrowses and copies filesInspect the EFI system partition
bcfg bootLists or edits boot entriesAdd or reorder a boot option
dmpstoreDumps UEFI variablesBack up or examine NVRAM settings
devices, drivers, dhShows devices and driver bindingsDiagnose a disk the firmware cannot see
memmapPrints the firmware memory mapInvestigate memory reservation issues
edit, hexeditEdits text or binary filesCorrect a configuration file
resetRestarts or powers off the systemReboot after a firmware change
Frequently used UEFI Shell commands

Command availability depends on the shell support level defined by the specification. A minimal embedded shell may lack edit or network commands, so administrators often carry a full-featured shell binary on removable media.

UEFI Shell compared with other pre-boot tools

The UEFI Shell is one of several pre-boot interfaces, and each serves a different purpose. The BIOS setup utility changes settings through menus, the boot menu selects a single device, and a bootloader such as GRUB starts an operating system. The shell is the only one that offers scriptable, general-purpose access to firmware services.

The comparison below shows where each tool fits.

ToolInterfaceMain purposeScriptable
UEFI ShellCommand lineDiagnostics, file and variable tasksYes, with .nsh scripts
BIOS setup utilityMenusFirmware configurationNo
Boot menuSingle listOne-time boot device choiceNo
GRUB command lineCommand lineLoading an OS kernelYes, with GRUB scripts
Legacy DOS boot diskCommand lineBIOS-era flashing and repairYes, with batch files
Pre-boot interfaces and their roles

Practical uses of the UEFI Shell

The UEFI Shell is most valuable when the operating system cannot start or when a task must happen below the operating system. Typical uses include repairing boot entries, running vendor firmware update tools, testing hardware in manufacturing and starting an operating system loader manually.

  • Recovering a lost boot entry by running bcfg boot add with the path to the OS loader.
  • Flashing firmware for motherboards, RAID controllers or network adapters with vendor EFI tools.
  • Starting a loader by hand, for example fs0:\EFI\ubuntu\grubx64.efi, to confirm it works.
  • Automating factory tests and burn-in with startup scripts on production lines.
  • Inspecting the EFI system partition when partition contents are suspected to be damaged.

Many systems no longer show a shell option in their menus. In that case the shell binary can be placed at \EFI\BOOT\BOOTX64.EFI on a FAT32-formatted USB drive, which the firmware treats as removable boot media.

Security risks and limitations

Because the UEFI Shell has unrestricted access to firmware services, it is a powerful attack tool. Anyone with physical access can read disks that are not encrypted, change boot order or modify UEFI variables. With Secure Boot enabled, an unsigned shell binary will not run, and many vendors no longer ship a signed shell for that reason.

The shell also has functional limits: it reads only file systems the firmware supports, usually FAT12, FAT16 and FAT32, so NTFS, ext4 or APFS volumes appear only as raw block devices unless extra drivers are loaded.

The table below pairs common problems with their causes and fixes.

SymptomLikely causeFix
Shell refuses to startSecure Boot blocks an unsigned binaryUse a signed tool or disable Secure Boot temporarily
Disk not listed as fs0:File system is not FATLoad a file system driver or use FAT32 media
New USB drive not visibleMappings are staleRun map -r
Boot entry change ignoredFirmware rewrites BootOrderSet the order in setup or update firmware
Shell starts unexpectedlyNo valid OS loader was foundRepair the EFI system partition
Common UEFI Shell problems

Put simply

The UEFI Shell is a small text-based control panel built into modern computers. It works before Windows, macOS or Linux starts, at the point when only the motherboard firmware is running.

Think of it as a mechanic’s toolbox for the moments before startup. If the computer cannot find its operating system, a technician can open the shell, look at the disks, fix the list of startup options or update the firmware, and then restart the machine normally.

In practice

A system administrator replaces the system drive of a Linux workstation by cloning it to a larger NVMe SSD. After the swap, the firmware reports that no bootable device was found, because the UEFI boot entry still points to the old disk. The machine has no operating system available to repair itself.

The administrator boots a USB drive containing the UEFI Shell, runs map -r and finds the EFI system partition on fs1:. Running bcfg boot dump confirms the stale entry, and bcfg boot add 0 fs1:\EFI\debian\shimx64.efi "Debian" creates a new one at the top of the boot order. After reset, the workstation boots normally within two minutes, without reinstalling the bootloader or the operating system.