LinuxCommandLibrary

systemctl-import-environment

Import variables into service manager

TLDR

Import environment variable

$ systemctl import-environment [VARIABLE]
copy
Import multiple variables
$ systemctl import-environment [VAR1 VAR2 ...]
copy
Import for user services
$ systemctl import-environment [VARIABLE] --user
copy

SYNOPSIS

systemctl import-environment VARIABLE...

DESCRIPTION

systemctl import-environment imports environment variables from the current shell session into the systemd service manager's environment. These imported variables become available to all units started by the service manager.
This is commonly used with `--user` to pass display-related variables (like DISPLAY, WAYLANDDISPLAY, or XDGSESSION_ID) from the login session to user services.

PARAMETERS

--user

Import into user service manager environment
--system
Import into system manager environment (default)

CAVEATS

Only affects services started after the import. Does not affect already running services. The system service manager typically runs in a minimal environment; importing user session variables may not be appropriate.

HISTORY

The import-environment subcommand enables proper integration between login sessions and systemd user services, solving the problem of user services not having access to session environment variables.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community