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:
| Scope | Who Sees It | Persists After Reboot? |
|---|---|---|
| System-wide | All users and processes | Yes |
| User-level | Only the current user | Yes |
| Session-level | Only the current terminal session | No |
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)
- Press Windows + S and search for Edit the system environment variables
- Click Environment Variables at the bottom of the System Properties window
- Under User variables (for your account only) or System variables (for all users), click New
- Enter the Variable name and Variable value
- 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: