Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 783 Bytes

persist-environment-variables-after-reboot.md

File metadata and controls

27 lines (19 loc) · 783 Bytes

Persist Environment Variables After Reboot

I've just come across a way to persist env variables after reboot with a simple command.

Following these steps assuming you have a .env file with the following content located in your home directory:

MY_NAME=John
MY_PASSWORD=123456
  1. Log into the machine and open the .bash_profile file.
  2. Add the following line in the end of the file, replacing joshua with your own username:
set -o allexport; source /home/joshua/.env; set +o allexport
  1. Save and exit the file.
  2. Log out and log in again.
  3. To verify that the environment variables have been persisted, run the following command in the console:
printenv

This should print out the environment variables that you set in the .env file.