Questions tagged [environment-variables]

Environment variables are configuration options that can be set in a shell or other similar environments. All programs started from within the shell can read them and configure themselves.

Environment variables are key-value-pair configuration options like KEY=valueor FOO=bar. Environment variables allow you to configure a program before it gets executed and without the need to store these variables in proprietary configuration files.

They are present on all POSIX systems (Unix, Linux, BSD, Mac OS, DOS, Windows, ...). Environment variables can be set by any shell and read by nearly any programming language.

Some programming languages allow you to set Environment variables, but they only persist within the current process. You can't set them to be visible by the calling shell. So they are not useful for inter-process communication.

410 questions
6
votes
2 answers

How to tell start-stop-daemon to update $HOME and $USER accordingly to --chuid parameter

I'm trying to run a service that uses $HOME and $USER environment variables. I could set them in service itself, but that would only be a temporary solution. Let's say I have a script test.sh with following content: echo $USER And I run it with…
iElectric
  • 358
  • 1
  • 5
  • 14
5
votes
1 answer

In a nginx configuration file, how to define a fastcgi_param that contains the "$" sign?

I'm trying to define a few environment variables for a PHP application but one of these variables contains the "$" sign. When I test the configuration file with nginx -t, I get an error message telling me that a variable does not exist. It seems to…
5
votes
1 answer

Passing multiple environment variables a process managed by a supervisor

I need to proxy multiple environment variables from /etc/environment to a process managed by a supervisor. The following configuration worked for me with supervisor 3.0r1-1 but supervisor 3.2.0-2 reports an…
Kolyunya
  • 217
  • 1
  • 3
  • 9
5
votes
3 answers

Why does 'ansible -a "env"' return a different environment PATH than my user?

When I ssh into a remote server and run env I get back the following PATH: PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/myusername/bin In contrast, when I execute the ansible command ansible -a…
Pretzel
  • 103
  • 1
  • 9
5
votes
3 answers

Load users environment variables in a cronjob

How can I load the users environment variables in a cronjob? I have a cronjob which should start a script every minute on my Ubuntu machine: * * * * * /home/user/myscript.sh; In this script I want to use environment variables like $JAVA_HOME and…
Sebastian Barth
  • 151
  • 1
  • 1
  • 6
5
votes
1 answer

Environment variable not available in python

I have a pretty interesting problem regarding environment variables, and googling around didn't show me any meaningful results: $ echo $BUCKET && python -c "import os; print os.environ['BUCKET']" mule-uploader-demo Traceback (most recent call…
Gabi Purcaru
  • 153
  • 1
  • 5
5
votes
4 answers

Will a Local System service notice changes to environment variables in Windows 2008 R2 without a reboot?

Microsoft has a knowledge base article, last reviewed in June 2007, which states: If you update environment variables or add new environment variables, you must restart the computer before the changes that you make affect services that run under…
5
votes
1 answer

How to reload environment variables file in a running Docker container

I have a running container with an environment variables file mounted as such: docker run -d --env-file ./env.list my/image and everything is working well, now I have updated my ./env.list file and would like the updated files to be reflected. Tried…
Mulkave
  • 183
  • 1
  • 2
  • 5
5
votes
8 answers

How to specify root's environment variable?

I do rails development. In this app, I need to specify the environment variable LD_LIBRARY_PATH = /usr/local/oracle/lib, but when I run the app with sudo script/server, it doesn't run because that library path is not in root's env. What should I do…
Wendy
5
votes
1 answer

grep is inconsistently defaulting to grep -P?

I have a script that does some housekeeping that works perfectly well when invoked from an interactive shell, but did nothing when invoked by cron. To troubleshoot this I started a shell with a 'blank' environment with the command: env -i /bin/bash…
Sammitch
  • 2,111
  • 1
  • 21
  • 35
5
votes
2 answers

Is there a good reason not to add sbin to the default PATH?

Background: The PATH environment variable specifies the directories to be searched through when a command is issued without specifying a path. "sbin" paths (/sbin, /usr/sbin) are intended to house administrative utilities, such that many *nix…
Joshua Miller
  • 1,378
  • 2
  • 11
  • 14
5
votes
2 answers

Preventing bash tab completion of an environment variable with a FS path value from removing the environment variable name

Friends, I am using GNU bash as my shell on Linux: $ bash --version GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later…
5
votes
1 answer

sudo does not preserve TMPDIR

The sudo manpage tells me, that I can preserve the environment by passing the -E option, which does not work in the case of $TMPDIR: > env | grep TMPDIR TMPDIR=/localdata/tmp > sudo env | grep TMPDIR [no output] > sudo -E env | grep TMPDIR [no…
5
votes
2 answers

Environment Varibales in MySQL configuration file?

It is possible to use environment variables in an Apache .conf file, but what about MySQL, is there a way to use them in the MySQL configuration file (my.ini/my.cfg)? The closest thing I could find was a MySQL man-page that mentions some variables…
Synetech
  • 948
  • 1
  • 12
  • 27
5
votes
3 answers

using local LS_COLORS on remote server via ssh without modifying remote server

I have access to loads of different ssh accounts, several hundred I'd imagine, that I use on different occasions. Some of them are personal, some of them I've gotten from clients and are shared, and loads of them are temporary. Created for one use,…
neuron
  • 151
  • 6