When authoring a systemd service file, it is common to specify the Environment and WorkingDirectory, both specified in systemd.exec(5). To help debugging, I want to run a command (frequently a shell) with the environment variables set, and at the specified working directory. The systemd-run --shell looks promising, except that it only creates an empty environment. That said, it does have --working-directory and --setenv, so the values could be extracted via systemctl show, and put into systemd-run. It should be possible to write a script to automate this.
When authoring a systemd service file, it is common to specify the
Environment
andWorkingDirectory
, both specified insystemd.exec(5)
. To help debugging, I want to run a command (frequently a shell) with the environment variables set, and at the specified working directory. Thesystemd-run --shell
looks promising, except that it only creates an empty environment. That said, it does have--working-directory
and--setenv
, so the values could be extracted viasystemctl show
, and put intosystemd-run
. It should be possible to write a script to automate this.