Questions tagged [environment-variables]
Environment variables are system-wide variables which share the same value. These variables are often parsed by the shell when executing commands, and are expanded into their appropriate variable. For example, this allows users to move file locations without needing to update hard-coded paths in scripts (they just have to update the environment variable).
1,299
questions
785
votes
8
answers
2.5m
views
How can I display the contents of an environment variable from the command prompt in Windows 7?
In Windows 7, when I start the Command prompt, is there any command to display the contents of an environment variable (such as the JAVA_HOME or PATH variables)?
I have tried with echo $PATH, echo ...
410
votes
5
answers
1.1m
views
What are PATH and other environment variables, and how can I set or use them?
Questions about
setting environment variables
the PATH
are very common here, and in most cases the answers are very similar to each other. In the future it would be nice to have a good Q/A for this....
307
votes
5
answers
949k
views
Setting and getting Windows environment variables from the command prompt?
I want to set an environment variable from the command prompt and then be able to access it globally (for instance, I should see it by going to System -> Environment Variables).
When I use the set ...
304
votes
5
answers
316k
views
Is there a list of Windows special directories/shortcuts (like %TEMP%)?
I'm looking for a reference list of shortcuts like %TEMP%.
When I'm using Windows+R or Windows Explorer and type %temp%, the Windows Explorer takes me to the Temp directory. Are there more of these ...
263
votes
6
answers
128k
views
Choosing between .bashrc, .profile, .bash_profile, etc [duplicate]
This is embarrassing, but after many years of using POSIX systems full time, I still have a hard time figuring out if a shell customization should go in .bashrc, .profile, or somewhere else. Not to ...
229
votes
2
answers
362k
views
How to reload /etc/environment without rebooting?
/etc/environment is officially the correct place for system wide environment variables. But how can I reload the assignments in this file without rebooting or relogging?
Interestingly enough google ...
147
votes
11
answers
219k
views
When ssh'ing, how can I set an environment variable on the server that changes from session to session?
When I ssh into a server, how can I pass an environment variable from the client to the server? This environment variable changes between different invocations of ssh so I don't want to overwrite $...
139
votes
4
answers
187k
views
Change environment variables as standard user
When clicking on "Advanced system settings", I need to login as the administrator and hence only edit the administrators environment variables (in addition to the machine wide ones). How do I edit the ...
130
votes
4
answers
137k
views
What is the difference between SETX and SET in environment variables in Windows
What is the difference between SETX and SET?
As per my understanding:
Both are used to set environment variables
SETX is for user variables.
SET is for shell variables.
113
votes
4
answers
27k
views
'less' command clearing screen upon exit - how to switch it off?
How to force the less program to not clear the screen upon exit?
I'd like it to behave like git log command:
it leaves the recently seen page on screen upon exiting
it does not exit the less even ...
97
votes
4
answers
75k
views
Windows 7's PATH and environment variables are corrupted
I have no clue, but lately I've been having this problem. After running my workstation suddenly something destroys PATH and lots of stuff stops working. Initially, my path had MANY directories listed (...
97
votes
11
answers
118k
views
Overcoming the 1024 character limit with setx
I am trying to set environment variables using the setx command, such as follows
setx PATH "f:\common tools\git\bin;f:\common
tools\python\app;f:\common tools\python\app\scripts;f:\common
tools\...
96
votes
4
answers
14k
views
Difference between "a=b" and "export a=b" in bash
What's the difference between:
a=b
and
export a=b
In bash?
I understand that they both define environment variables, but I don't fully understand the difference.
72
votes
2
answers
265k
views
Path Environment Variable Windows 10. Echo %Path% on command prompt shows only %Path% [duplicate]
My variable value in path is as follows
C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program ...
68
votes
3
answers
139k
views
How to include environment variable in bash line CURL?
Trying to get Transmission to notify when download complete.
This works:
curl -u <my-api-token>: \
-X POST https://api.pushbullet.com/v2/pushes \
--header 'Content-Type: application/json' \...
61
votes
6
answers
81k
views
Overriding HOMEDRIVE and HOMEPATH as a Windows 7 user
My employer has an Active Directory group policy which sets my Windows 7 laptop HOMEDRIVE to "M:" (a mapped network drive) and my HOMEPATH to "\". Since I have read-only permissions for the root of ...
59
votes
2
answers
74k
views
User vs. System Environment Variables: Do System Variables Override User Variables?
I have elevated rights to my laptop but not admin rights. Admin rights are required to modify system environment variables. I expected that if I created a user environment variable with the same name ...
58
votes
4
answers
27k
views
What is SHELL-FORMAT in envsubst?
When I stumbled upon envsubst I wanted to use it for replacing only specific variables and suspected that the SHELL-FORMAT parameter might be what is wanted but I cannot get it to work.
Unfortunately,...
56
votes
2
answers
74k
views
What is the difference between `/etc/environment` and `/etc/profile`?
I understand that the former is loaded prior to the latter, but what is the difference in their purpose and otherwise? Are there any good reasons I should set some variables in one and not the other?
...
56
votes
3
answers
122k
views
Are HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables standard?
It seems that a lot of programs are designed to read these environment variables to decide what proxy to go through in order to connect to a resource on the internet. Those programs may also have ...
54
votes
6
answers
120k
views
How do I make sudo preserve my environment variables?
Using sudo 1.7.4p4 on Solaris 5.10 and sudo 1.6.7p5 on RHEL4 u6 I can't see how to preserve my environment variables, for instance $PYTHONPATH. I've added this line to sudoers, but it doesn't make any ...
49
votes
12
answers
93k
views
Why can't Windows handle an environment variable in Path?
My colleague and I have identical Dell workstations with Windows XP Professional x64 edition installed.
My Path environment variable starts with:
%JAVA_HOME%\bin;...
My colleague's Path variable ...
48
votes
3
answers
74k
views
Environment variables in bash_profile or bashrc?
I have found this question [blog]: Difference between .bashrc and .bash_profile very useful but after seeing the most voted answer (very good by the way) I have further questions. Towards the end of ...
47
votes
9
answers
289k
views
How to restore the Path environment variable I deleted?
I accidentally deleted the Path environment variable by creating a new one with Path name. How can I restore my old Path environment variable?
46
votes
5
answers
50k
views
How do I see a list of all currently defined environment variables in a Linux bash terminal?
In a Linux bash terminal, there are often many environment variables that have been set, like $PATH and $HOME.
Is it possible to see all of the environment variables that have been set? How?
46
votes
10
answers
45k
views
Cannot resolve %windir% / Cannot modify %path% or %path% being reset on boot
See Updates 3 and 4 below for how the issue has evolved
My computer (Windows 7 x64, Lenovo Thinkpad T530) is having an issue resolving %windir%. After boot-up, everything works fine. At some point ...
45
votes
2
answers
24k
views
What's the ZSH equivalent of BASH's $PROMPT_COMMAND?
BASH supports a $PROMPT_COMMAND environment variable that defines a command to be executed before any first-level interactive prompt. I'm looking for a ZSH equilvalent of that.
The documentation says ...
44
votes
1
answer
83k
views
How do you set environment variables for a single command on Windows? [duplicate]
Is there a way to set environment variables for a single command on Windows like ENVVAR=abc command on Unix?
Variables set by set command on Windows seem to remain for the following commands, but ...
43
votes
6
answers
27k
views
How to remove a path from $PATH variable in fish?
I am using fish as my shell in Debian and recently (after some upgrade) whenever I try to use command completion I have:
set: No such file or directory
set: Could not add component /usr/lib/x86_64-...
42
votes
3
answers
55k
views
Is the HOME environment variable normally set in Windows?
To be clear, I'm not asking can it be set or how to set it, I'm asking is it already set at all on a new copy of Windows. The ideal way to find this out would be to install a fresh copy of Windows on ...
40
votes
5
answers
5k
views
Does the Windows Command Prompt search somewhere other than those locations specified by the PATH variable when launching application programs?
I tried the following experiment.
Before I start, I checked the PATH variable from cmd, which has the following value:
Path=C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS ...
40
votes
4
answers
35k
views
LANG and LANGUAGE environment variable in Debian based systems
It seems both the LANG and LANGUAGE environment variable are used by some programs to determine their user interface language.
What are the exact semantics of these variables and where can I read ...
39
votes
3
answers
133k
views
Where do I set DYLD_LIBRARY_PATH on Mac OS X, and is it a good idea?
I am trying to install a solver written in C++ on my Mac (OS X), for use with code I have written in XCode.
The solver documentation says this:
Be sure to have "." in your DYLD_LIBRARY_PATH ...
38
votes
5
answers
93k
views
Setting $HOME in PowerShell
How do I change my default home directory to "C:\Users\khornsby" for every time I open powershell?
I am running Windows 7. Below is info about the state of my environment.
Windows PowerShell
...
36
votes
3
answers
90k
views
On Windows, why java -version return Error: opening registry key 'Software\JavaSoft\Java Runtime Environment'?
I've removed all ancient Java 8 install on my computer.
I've downloaded latest openjdk 11 from https://jdk.java.net/11/ and extracted the content to C:\Program Files\Java\.
I've setup system ...
35
votes
3
answers
70k
views
How to extract environment variables from system restore point, Windows 7 64-bit
Recently a (badly written) piece of software erased my PATH variable. I've been installing software for years and recovering every single entry would be cumbersome. An even more cumbersome solution ...
33
votes
4
answers
41k
views
Add a directory and all subdirectories to the PATH variable with a single entry
I've got a directory in my home folder in which I place command-line software (CMD_Software). I put each piece of software in its own directory within CMD_Software in order to avoid clutter.
I would ...
33
votes
2
answers
148k
views
HOSTNAME environment variable on Linux
On my Linux box (Gentoo Linux 2.6.31 to be specific) I have noticed that the HOSTNAME environment variable is available in my shell, but not in scripts. For example,
$ echo $HOSTNAME
returns
...
32
votes
2
answers
95k
views
How can I set user environmental variables (such as PATH) from a non-administrator account on Windows 7
How can I set user environmental variables (such as PATH) from a non-administrator account on Windows 7?
On Windows XP I could go into the Advanced Settings in the System Control panel. However, on ...
30
votes
2
answers
74k
views
TEMP vs TMP in Environment Variables
Is it right to have these two environment variables TEMP and TMP? If I make changes to one should I make the same changes to the other? For example I was installing cygwin and the directions told me ...
29
votes
2
answers
13k
views
Why does Windows 10 list "Windows_NT" as OS?
When inspecting the Environment System Variables I noticed that the Environment Variable "OS" is set to "Windows_NT".
To my knowledge the Windows NT operating system was released ...
28
votes
5
answers
40k
views
Setting environment variables in OS X for GUI applications
How does one set up environment variables in Mac OS X such that they are available for GUI applications without using ~/.MacOSX/environment.plist or Login Hooks (since these are deprecated)?
28
votes
4
answers
154k
views
How do I reset the $PATH variable on Mac OS X?
I've messed up my path variable, and now some apps that I run raise errors saying Command Not Found (error 127) for commands like date and sleep. These commands work fine when executed directly in the ...
28
votes
7
answers
10k
views
What is the simplest scriptable way to check whether a shell variable is exported?
For some shell sessions I want to be able to print a warning flag if a shell variable is not set and exported.
It is fairly simple to do something like this to print "Error" in the prompt if SET_ME ...
27
votes
5
answers
117k
views
Where is the $HOME environment variable set?
I'm looking for the place where $HOME environment variable set.
It is after login, to my mind.
I'm using Linux debian 2.6.32-5-686.
27
votes
4
answers
206k
views
Easier way to change environment variables in Windows 8? [duplicate]
Possible Duplicate:
What are PATH and other environment variables, and how can I set or use them?
I know that I can edit my environment variables in windows 8 by going to
Start -> All Apps -&...
27
votes
5
answers
35k
views
How do I bypass restrictions on the length of the PATH variable
System Properties
This environment variable is too large. This dialog allows setting values up to 2047 characters long.
I use/have used a lot of software, and my PATH has grown as a result. When ...
27
votes
3
answers
18k
views
Prevent Windows System %PATH% from being prepended to user %PATH?
I know how to set system or user specific environment variables:
Now, the problem is that the PATH variable is treated such that the value you enter for the user PATH will be automatically appended ...
26
votes
5
answers
58k
views
How do I alias python3 on Windows?
I want to alias python3 to python on windows. I have already removed the alias for the microsoft store as described in this answer. However python3 is still not a known alias. How to I fix this?
26
votes
6
answers
20k
views
Adding an .exe to default path without adding the directory
For example, I want to add notepad++ to my PATH, however the directory also contains uninstall.exe and several other files/executables and I don't want them to "pollute" my path. Can I just add the ...