Sample Header Ad - 728x90

How can I set and export an environment variable in a systemd service?

1 vote
0 answers
2042 views
after starting agetty on my Raspberry Pi in order to attach a VT420 terminal to it, I still have an issue: The shell language must be set to en_US and exported by hand right after logging in on the terminal (my version of Raspbian has German locale). Motivation: The terminal does not support UTF-8 characters (and sometimes even stops working when receiving such a character), so I decided to fall back to English locale especially when logging in on the terminal. In all other cases (SSH etc.), UTF-8 is absolutely fine. I followed the suggestion set forth in question #455261 and added the following line to the systemd service file responsible for agetty: Environment="LANG=en_US" After a daemon reload and a restart of agetty, the login prompt is now in English, but when I start a program (say, df -h), its output is still in German and contains UTF-8 characters, causing the already-mentioned problems: pi@autoradio:/import/valen/autoradio $ df -h Dateisystem Grö …whereas the ö sequence should read as "ö". On the shell, I would say, export LANG=en_US, but I am not sure about how to export an env variable set in a systemd config. Does anybody know that? Thank you.
Asked by Neppomuk (364 rep)
Feb 9, 2019, 05:57 PM
Last activity: Feb 10, 2019, 02:59 PM