While developing a React app, I needed to use some environment variables. The way to do it is by using this syntax:  REACT_APP_NOT_SECRET_CODE=abcdef npm start      My first question is: How does that work? I don't know this linux thing, what's happening behind the scenes?  My second question is: How to I make more scalable? say I have file that looks like that  MY_VAR_1=123 MY_VAR_2=23332 MY_VAR_3=3232   How do I inject it to the npm process? I tried   cat .env | npm start    But it doesn't work  I guess after I understand the linux syntax I get be in a better position to use a file instead of inline data.  Thanks
122679
When I run this command:  https_proxy=http://myproxy.com/ aws [aws-param]   the proxy is picked up by the aws command line tool.   However - when I do this:  https_proxy=http://myproxy.com/  aws [aws-param]   the aws command doesn't pick up the proxy.   To me, they're the same from a unix point of view. Is this something about the way python reads environment variables?  My question is: Why does an inline variable definition work but a previous line does not for an aws command?
47053
Some context about the bug:      Bash supports exporting not just shell variables, but also shell   functions to other bash instances, via the process environment to   (indirect) child processes.  Current bash versions use an environment   variable named by the function name, and a function definition   starting with “() {” in the variable value to propagate function   definitions through the environment.  The vulnerability occurs because   bash does not stop after processing the function definition; it   continues to parse and execute shell commands following the function   definition.  For example, an environment variable setting of    VAR=() { ignored; }; /bin/id       will execute /bin/id when the environment is imported into the bash   process.   Source:   When was the bug introduced, and what is the patch that fully fixes it? (See )  What are the vulnerable versions beyond noted in the CVE (initially) (3.{0..2} and 4.{0..3})?  Has the buggy source code been reused in other projects?  Additional information is desirable.    Related:
77823
I need to set some environment variables such as the XDG spec ones, before KDE starts in such a way that kwin and any apps run from KDE will inherit them. Where could I do this, and how?
71791
Running Ubuntu 13.04, I'm trying to add variables to PATH for the session, which is , but nothing seems to work. Here's what it looks like:  JAVA_HOME          DEFAULT=/usr/lib/jvm/java-7-oracle IDEA_HOME          DEFAULT=/usr/local/idea-IU-129.451/bin LIGHTTABLE_HOME    DEFAULT=/usr/local/LightTable CLOUDIFY_HOME      DEFAULT=/home/eliranm/builds/gigaspaces-cloudify PATH               DEFAULT=${PATH}    OVERRIDE=${PATH}:${JAVA_HOME}:${IDEA_HOME}:${LIGHTTABLE_HOME}:${CLOUDIFY_HOME}   It seems all variables are set but the PATH, or that it is overridden somehow. I tried to prepend or append the ${PATH} variable, to use DEFAULT only, OVERRIDE only, tried to just set a hard-coded path as a value, all to no avail.  I'm following the recommendations from the Ubuntu help community, and I want to avoid concatenating hard-coded paths to the PATH inside /etc/environment as it's not the right scope, plus, it will be hard to maintain with no variables.  Others may be affected by this issue, , but no one provided a solution so far.  How to make this work?
118206
I was trying to run one of the scripts (for example, wrapper.sh) which internally executes other scripts using crontab. It works fine without any issues.  When I have created a environment file (which stores the passwords-DB and paths) and trying to execute the main script (wrapper.sh) the cron entry doesn't work on those scripts which are called internally in the wrapper.  NOTE: I tried changing PATH, added env file location before the script in cron but it still didn't work:  9 9 * * * . /$SOMEPATH/some.env; /$SOMEPATH/wrapper.sh   The environment script and wrapper.sh are in same path. when the cron runs it passes the env variables to wrapper but not to the scripts which are called internally in wrapper. Also a mail is received on /var/mail/$user saying the env file as "No such file or Directory". I've gone through many posts but couldn't figure out the resolution.
40465
In shell scripts one specifies language interpreter on shebang(#!) line. As far as I know, it is recommended to use #!/usr/bin/env bash because env is always located in /usr/bin directory while location of bash may vary from system to system. However, are there any technical differences if bash is started directly with /bin/bash or through env utility? In addition, am I correct that if I do not specify any variables for env, the bash is started in unmodified environment?
35881
I want to start a process as another uid and it should not need any information from $(env), so I strip the environment prior to the sudo -u powerlessuser /bin/processCmd, that is I run this  env -i sudo -u powerlessuser /bin/processCmd   it turns out sudo thinks it is necessary to repopulate the environment, which I would like to ask it not to do. There is for instance $SUDO_USER set which even tells the powerlessuser's /bin/processCmd about me(tm) that called the command, which I find very indiscrete. Any help?  It is as I figured also possible to use env -i stripping after the sudo, i.e. do this:  sudo -u powerlessuser /usr/bin/env -i /bin/processCmd   which solves the problem somewhat, yet I would really like to know if there is a way to make sudo not add any information in the first place, I browsed  in which I found documentation that sudo adds environment and which, but no help how to make sudo not do that  @terdon♦: I want all environment variables cleaned that are not necessary. I am unable to tell which environmental variables are necessary but just to stick to the question, I have not found the reason why $SUDO_USER would be needed by a process to be called as an unpriveledged user. Therefore I would be satisfied to know how to tell sudo not to leak SUDO_USER  Update - xy-problem issue  As much as I am very interested in avoiding anything of the kind of a xy-problem, I fear it is not the case here. That is because, I do not have actually a different problem as the one stated in the question, namely that searching a way to make sudo not do something, which I can reasonably expect: Sudo get an cleaned up environment and should at best not add stuff to it, i.e. $SUDO_USER. For this reason I am rather very convinced not to have any other problem, since I have already a cure to that issue that sudo leaves me with, i.e. I can do:  sudo -u powerlessuser /usr/bin/env -i /bin/processCmd   which "cleans up after sudo", so in no way is my problem something else, because using the subsequent env -i solved any problem there. The only thing I ask is for knowing if there would have been indeed a way like  sudo --empty-env which then would spawn the new process with an emptied environment, one that at least would not tell $SUDO_USER which uid ran the original sudo.   For all that showed interest in helping me with this question, I like to thank them! I also leave some time, maybe there is such a --empty-env switch possibility. If not maybe somebody that is inside of sudo can tell, i.e. with reference to the sources that such a task is impossible, as sudo cannot but put that undesired $SUDO_USER inside.  Again no xy-problem, for the fact, that it is not really a problem to start with, i.e I do not suffer from the shortcomings of sudo here, as it is solved by a subsequent env -i, which in "unix philosophy" is the one thing that env -i does well, i.e. clean the environment. I should maybe not even have expected any reasonable behavior from sudo there, as sudo has a different one-purpose, which is not concerned about environment variables leaking. Even though, the fact that sudo does offer some flags relating to environment variables misleads into thinking it would deal with environment variables well.
90573
If I run this bash command and prefix the statement, so that the variable fruit should exist, but only for the duration of this command:  $ fruit=apple echo $fruit  $   The result is an empty line. why?  To quote a comment from wildcard on :     parameter expansion is done by the shell, and the "fruit" variable is   not a shell variable; it's only an environment variable within the   environment of the "echo" command   An environment variable is still a variable, so surely this should still be available to the echo command?
70475
When loading a python virtual environment I need to run:  source venv/bin/activate   I want an alias for this command because I have to run it all the time. So I put the following in a file called "load.sh":  #!/bin/bash source venv/bin/activate   And ran  chmod +x load.sh   However, now when I run ./load.sh there is no effect. My suspicion is that the word "source" may be the issue. But I don't know. Any ideas? Thanks.
93297
I wanted to set environment variables JAVA_HOME and PATH. So I wanted to open ~/.pam_environment since it is the best place to set environment variables relevant to a particular user according to the link . The link states:  Session-wide environment variables Environment variable settings that should affect just a particular user (rather then the &gt;system as a whole) should be set into: ~/.pam_environment - This file is specifically meant for setting a user's  environment. It is not a script file, but rather consists of assignment expressions, one per line.  The problem I have is that I am not able to open the file ~/.pam_environment by using the command gedit ~/.pam_environment. I do not know whether this is the right way to open this file, please point me in the right direction.
9741
As example to my question, my ~/.bashrc file contains this lines:  export LD_LIBRARY_PATH=/opt/intel/mkl/lib/ia32:$LD_LIBRARY_PATH export LD_PRELOAD=/opt/intel/mkl/lib/ia32/libmkl_core.so   so that Numpy (Python) could find libraries that it needs to run, as it's build with MKL and Intel compilers. This workflow isn't the best, but that's another story.  My question is how can I pass arbitrary variables (like those in ~/.bashrc) when I run program with 'sudo' (but not root)?  Currently, if I run:  sudo python -c "import numpy"   I get an error:  ImportError: libimf.so: cannot open shared object file: No such file or directory*   Some suggestions as sudo -i or sudo -E does not change anything here.    Edit:  I can't answer my question (not enough points :D ) but I'll comment here, in a hope that there are other Linux newbies wondering about sudo traps.  [Only temporarily!] This works for me (~/.bashrc):  alias sudo='sudo env PATH=$PATH VAR1=SOME_VALUE VAR2=SOME_VALUE...'
50102
When I open my non-login shell in Ubuntu, my present working directory is /home/user_name (my $HOME environment variable), but I want to change this such that when I start my terminal I am in some other directory.  I have read that when I start my terminal in Ubuntu a .bashrc file is sourced. So I added   export HOME=/home/user_name/Documents    to my .bashrc file. Now, when I open my terminal I am still in /home/user_name directory.  How can I change this?
66311
Possible Duplicate:          I was trying to figure out how to export my environmental via script instead of changing my .bashrc file.   I found  that said:     Variables can only be exported to subordinate processes, you can't   pass them back up to the parent. If you really want your script to   affect the parent shell's environment, run the script as  . ./yourprogram    I just want to know what the difference is between . ./script and ./script?  When I look at it, they booth mean to me, run the script from the current directory?
55260
If I run these commands from a script:  #my.sh PWD=bla sed 's/xxx/'$PWD'/' ... $ ./my.sh xxx bla   it is fine.  But, if I run:  #my.sh sed 's/xxx/'$PWD'/' ... $ ./my.sh $ sed: -e expression #1, char 8: Unknown option to `s'    I read in tutorials that to substitute environment variables from shell you need to stop, and 'out quote' the $varname part so that it is not substituted directly, which is what I did, and which works only if the variable is defined immediately before.  How can I get sed to recognize a $var as an environment variable as it is defined in the shell?
78052
Just wondering if there is any difference between:    echo "running the npm patch" &gt;&amp;2;   and   echo "running the npm patch" &amp;&gt;2;   I have actually never really understand that syntax.
69962
I have an application which takes as an input attributes in double quotes embedded in single quotes. Take for example this right command:  command -p 'cluster="cl1"'   In order to automate it, I created a bash file using $CLUSTER as a variable. How should be my command? In other words, what should I put instead of cl1?  Please note that, If I modified the above command, it won't be accepted. For instance: command -p "cluster=cl1" is not accepted
4563
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.  So the question is: What are environment variables, like the executable PATH, and how can I change and use them on major operating systems?  A good answer would include a simple explanation of what environment variables and especially PATH mean to the OS, as well as simple guidelines on how to set and read them accordingly.