19
How do I set environment variables that persist after reboot?
Loading...
Q&A · Answered
How do I set environment variables that persist after reboot?
Accepted answer
# For current user - add to ~/.bashrc
echo 'export MY_VAR="value"' >> ~/.bashrc
source ~/.bashrc
# For all users - add to /etc/environment
sudo nano /etc/environment
MY_VAR="value"
# For services - use systemd override
sudo systemctl edit myservice
[Service]
Environment="MY_VAR=value"Say what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.