Linux – How to use the `$HOME` environment variable in systemd service files

initlinuxsystemd

I am trying to use the $HOME environment variable in the ExecStart. I tried many different things like $HOME and ${HOME} but nothing seems to be working

ExecStart=${HOME}/bin/some-binary

Anyone knows the correct format for this?

Best Answer

I think this is what you're looking for: https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers.

Specifically, %h should expand to the current user's home dir.