systemctl-is-enabled
Check if a service is enabled
TLDR
Show the enablement state
Suppress output and return only the exit code
Show installation targets and symlink paths
SYNOPSIS
systemctl is-enabled [OPTIONS...] UNIT...
PARAMETERS
UNIT...
One or more systemd unit file names (e.g., apache2.service). These are the units whose enabled status will be checked.
-h, --help
Displays a brief help message about the command and exits.
--quiet
Suppresses the normal output string ("enabled", "disabled", etc.), returning only the exit status. This option is particularly useful when scripting.
DESCRIPTION
systemctl is-enabled is a subcommand of the systemctl utility, which is the primary interface for controlling and querying the systemd init system. This command is used to determine the configured startup behavior of one or more systemd unit files, such as services (.service), sockets (.socket), or mount points (.mount). It does not indicate whether a unit is currently running, but rather if it's set to start automatically during boot or on demand.
The command outputs a string indicating the unit's state, which can be "enabled", "disabled", "static", "masked", or "generated". An "enabled" unit means systemd will attempt to start it. A "disabled" unit will not start automatically. "Static" units are typically base units (like local-fs.target) that cannot be explicitly enabled or disabled but are pulled in by other units. "Masked" units are completely disabled and prevented from starting, even if other units try to pull them in. "Generated" units are created dynamically, often by other services or based on system configuration.
systemctl is-enabled returns an exit code of 0 if all specified units are enabled, and 1 otherwise (for disabled, static, masked, or invalid units/arguments). This makes it highly valuable for shell scripting and automation tasks where conditional logic based on service enablement is required. Understanding the distinction between a unit's enabled state (its configured startup behavior) and its active state (whether it's currently running) is crucial for effective system management with systemd.
CAVEATS
A unit being reported as "enabled" signifies its configuration for automatic startup, not its current operational status. To check if a unit is currently running, use systemctl status.
Units reported as "static" cannot be explicitly enabled or disabled via systemctl enable/disable as they are typically fundamental components or dependencies for other units.
The command returns an exit code of 1 for "disabled", "static", "masked", or if an invalid unit name is provided, making a distinction solely based on exit code for "enabled" vs. "not enabled".
<B>UNDERSTANDING UNIT STATES</B>
The output of is-enabled provides specific states:
enabled: The unit is configured to start automatically during boot or on demand.
disabled: The unit is not configured for automatic startup.
static: The unit cannot be explicitly enabled or disabled; it's typically a dependency or an integral system component.
masked: The unit is completely disabled and prevented from starting, even if other units depend on it. This is a stronger form of disabling.
generated: The unit was created dynamically at runtime by systemd or another service.
<B>EXIT CODES FOR SCRIPTING</B>
The command's exit code is crucial for automation:
0: All specified units are enabled.
1: One or more units are disabled, static, masked, or the command received an invalid unit name or argument. This allows shell scripts to easily check if a service is configured to start.
HISTORY
The is-enabled subcommand is an integral part of systemctl, the primary control utility for the systemd init system. systemd was developed to modernize the Linux boot process and service management, gradually replacing older init systems like SysVinit and Upstart across major Linux distributions starting in the early 2010s. The is-enabled command provides a clear, standardized, and programmatic way to query the configured startup state of systemd units, a functionality that was often more fragmented or less standardized in previous init systems.


