LinuxCommandLibrary

systemctl-emergency

Enter emergency recovery shell

TLDR

Enter emergency mode

$ systemctl emergency
copy

Enter emergency mode without blocking (return immediately)
$ systemctl emergency --no-block
copy

SYNOPSIS

systemctl emergency [OPTIONS]

PARAMETERS

--no-block
    Do not wait for the started job to complete. If this option is specified, the `systemctl` command will exit after the job has been enqueued.

--job-mode=MODE
    If a new job is started but conflicts with an already existing pending job, this option controls how to resolve the conflict. MODE can be 'fail', 'replace', 'replace-irreversibly', 'isolate', 'flush', or 'ignore'. The default is 'replace'.

-h, --help
    Show a short help text and exit.

--version
    Show a short version string and exit.

DESCRIPTION

The `systemctl emergency` command is used to bring the system into emergency mode, a highly stripped-down operational state. This mode is typically invoked when the system fails to boot normally, or when administrators need to perform critical maintenance or recovery operations on a severely damaged system.

In emergency mode, the system boots with the absolute minimum number of services and mounts the root filesystem, often initially in a read-only state. It then presents a root shell to the user, allowing them to manually diagnose and repair issues that prevent the system from booting correctly. Common uses include fixing filesystem corruption, repairing `fstab` entries, or troubleshooting issues with critical services. It provides a more basic environment than rescue mode (`systemctl rescue`), which attempts to load more services and mount more filesystems. Access to emergency mode usually requires the root password.

CAVEATS

  • Requires the root password to access the shell.
  • Many services and daemons will not be running, and most filesystems (including the root filesystem) may initially be mounted read-only. You will likely need to remount the root filesystem read-write (`mount -o remount,rw /`) and potentially mount other necessary filesystems before performing repairs.
  • Network services are typically unavailable, limiting access to external resources.
  • This mode is for diagnostic and repair purposes only, not for normal system operation.

EXITING EMERGENCY MODE

To exit emergency mode after completing your repairs, you can usually type `exit` in the shell or use `systemctl default` to switch back to the normal multi-user target. Alternatively, `systemctl reboot` will restart the system.

HOW TO ENTER

Besides `systemctl emergency` from a running system, you can enter emergency mode during boot by adding `systemd.unit=emergency.target` to the kernel command line in your boot loader (e.g., GRUB). Many distributions also offer an "Emergency Mode" option directly in the GRUB menu.

UNDERLYING TARGET

`systemctl emergency` is essentially a shortcut for `systemctl isolate emergency.target`. The `emergency.target` is a special systemd target unit designed to pull in only the most essential services needed for a minimal, interactive shell environment.

HISTORY

The concept of a low-level system recovery mode has existed in various forms across Unix-like operating systems. With the adoption of systemd as the default init system in many modern Linux distributions, the `systemctl emergency` command (and its underlying `emergency.target`) was introduced to provide a standardized and integrated method for entering this critical recovery state. It superseded older methods often relying on kernel boot parameters or specific runlevels (like runlevel 1 or 'single user mode' in SysVinit).

SEE ALSO

systemctl(1), systemctl rescue(1), systemctl isolate(1), mount(8), fstab(5), systemd.special(7)

Copied to clipboard