🍱 Env Vars

The many ways to configure Environment Variables in Linux

1. Export

This will setup an environment variable temporarily for the life of the shell session

export FOO="bar"

2. Bash

Update the .bashrc or .bash_profile to set the variable before every shell session.

nano ~/.bashrc
export FOO="bar"

3. System Environment

Set it permanently system wide.

nano /etc/environment
export FOO="bar"

4. .env

Create a .env file in one of your project directories. Your application may need a library like dotenv in Node.js to read the value.

export FOO="bar"

5. Systemd

See next video for setting environment variables with Systemd.

Questions? Let's chat

Open Discord