systemctl-show-environment
Show systemd manager's environment variables
TLDR
Display the environment block for the system
Display the environment block for the current user
SYNOPSIS
systemctl show-environment
PARAMETERS
--user
Operate on the user manager instance. By default, `systemctl` operates on the system manager instance.
--system
Operate on the system manager instance. This is the default behavior and is often implied.
--no-pager
Do not pipe output into a pager. Useful for scripting or capturing output without interaction.
--plain
Print output in a plain format without headers, useful for parsing in scripts.
--json=MODE
Output in JSON format. `MODE` can be `pretty` (indented) or `short` (single line), for machine-readable output.
DESCRIPTION
The systemctl show-environment command displays the environment block that the systemd system and service manager itself operates with. These environment variables are fundamental because they are inherited by default by all services, units, and processes that systemd spawns, unless those units explicitly override or clear specific variables. It provides a crucial snapshot of the foundational context in which many system processes execute.
Administrators and developers use this command to debug issues where services might be missing expected environment settings or to confirm that system-wide environment configurations, often set in files like /etc/systemd/system.conf.d/*.conf or /etc/environment, have been correctly applied and are visible to systemd. Unlike printenv or env, which show the environment of the current shell or a specific command, systemctl show-environment specifically queries the environment of the PID 1 systemd process, offering a system-wide perspective rather than a user-session specific one.
CAVEATS
- Service Overrides: While services inherit these variables by default, individual service units can override or clear specific environment variables within their .service files using directives like Environment= or EnvironmentFile=.
- Update Mechanism: Changes to systemd's global environment (e.g., via /etc/systemd/system.conf.d/) require systemctl daemon-reload and often a service restart or system reboot to take full effect and be reflected by show-environment.
- Security: Avoid placing highly sensitive information directly in systemd's global environment variables, as they can be widely accessible to processes.
<B>SOURCES OF ENVIRONMENT VARIABLES</B>
Systemd's global environment variables displayed by show-environment are primarily sourced from configuration files. Common locations include snippets in /etc/systemd/system.conf.d/ (e.g., DefaultEnvironment=), the traditional /etc/environment file (which systemd-environment-generator can read), and settings defined by other systemd components. These sources converge to build the environment block of the PID 1 process.
<B>IMPACT ON SERVICE EXECUTION</B>
Understanding systemd's environment is vital for troubleshooting service behavior. If a service fails to start or behaves unexpectedly due to missing or incorrect environment variables (e.g., PATH, LD_LIBRARY_PATH, or custom application variables), systemctl show-environment can help determine if the base systemd process provides the necessary context. If not, the issue might stem from how systemd itself is configured, rather than the service unit file directly.
HISTORY
The systemctl command, including its show-environment verb, emerged as an integral part of the systemd project. systemd was initially released in 2010 with the goal of replacing the traditional SysVinit and Upstart init systems in Linux distributions. As systemd became the de facto init system for many major distributions (like Fedora, RHEL, Debian, Ubuntu), systemctl became the primary interface for controlling and querying the system and services. The show-environment subcommand specifically provides administrators with essential visibility into the environment context of systemd itself, a feature crucial for modern system management and debugging in the systemd ecosystem.
SEE ALSO
systemctl(1), systemd(1), printenv(1), env(1), journalctl(1)