Your Guide to How To Add Environment Variable

What You Get:

Free Guide

Free, helpful information about Computers & Operating Systems and related How To Add Environment Variable topics.

Helpful Information

Get clear and easy-to-understand details about How To Add Environment Variable topics and resources.

Personalized Offers

Answer a few optional questions to receive offers or information related to Computers & Operating Systems. The survey is optional and not required to access your free guide.

How to Add an Environment Variable in Windows, macOS, and Linux

Environment variables are one of those behind-the-scenes tools that quietly power a huge amount of how your computer and software behave. Whether you're setting up a development environment, configuring a command-line tool, or pointing software to the right directory, knowing how to add an environment variable is a practical skill that pays off fast.

What Is an Environment Variable?

An environment variable is a named value stored at the operating system level that programs can read at runtime. Instead of hardcoding a file path, API key, or configuration setting directly into an application, developers (and the OS itself) use environment variables as flexible placeholders.

For example:

  • PATH tells your system where to look for executable programs
  • HOME stores the path to the current user's home directory
  • NODE_ENV tells a Node.js application whether it's running in development or production mode

These variables exist in a key=value format. The key is the variable name (usually uppercase by convention), and the value is the string it holds.

There are two main scopes to understand:

ScopeWho Sees ItPersists After Reboot?
System-wideAll users and processesYes
User-levelOnly the current userYes
Session-levelOnly the current terminal sessionNo

Which scope you need depends entirely on what the variable is for.

How to Add an Environment Variable on Windows 🖥️

Windows gives you two routes: a graphical interface and the command line.

Using the GUI (System Properties)

  1. Press Windows + S and search for Edit the system environment variables
  2. Click Environment Variables at the bottom of the System Properties window
  3. Under User variables (for your account only) or System variables (for all users), click New
  4. Enter the Variable name and Variable value
  5. Click OK through all open windows

Changes take effect for any new processes you launch. Already-open terminals won't see them until restarted.

Using the Command Line

To set a session-only variable in Command Prompt:

To set a persistent user-level variable via PowerShell: