How to set ENV variables on our local terminal

Nazif Altintas
1 min readJul 17, 2023

--

Setting environment variables on a local terminal depends on the operating system you are using. Here are instructions for setting environment variables on different operating systems:

Windows:

  1. Open the “Start” menu and search for “Environment Variables”.
  2. Click on “Edit the system environment variables” to open the System Properties window.
  3. In the System Properties window, click on the “Environment Variables” button.
  4. In the “User variables” or “System variables” section, click “New” to add a new variable.
  5. Enter the name and value for the environment variable, and click “OK” to save.

macOS/Linux:

  1. Open a terminal.

2. To set a temporary environment variable for the current session, use the following command:

export VARIABLE_NAME=value

3. To set a permanent environment variable for all terminal sessions, open the shell configuration file (e.g., ~/.bashrc, ~/.bash_profile, ~/.zshrc, etc.) using a text editor.

4. Add the following line at the end of the file:

export VARIABLE_NAME=value

5. Save the file and restart the terminal or run source ~/.bashrc (or the corresponding file for your shell) for the changes to take effect.

Remember to replace VARIABLE_NAME with the name you want for the environment variable and value with the desired value.

How to display ENV variables on our local terminal?

--

--