A set of dynamic variables that can affect the running processes.

learn more… | top users | synonyms

-2
votes
0answers
26 views

Oracle in Solaris [closed]

I want to access DB_USER & DB_USER_PWD but they are not to scene in the environment variables. Oracle is not installed in my system. Is it necessary that oracle is installed in my system then only ...
2
votes
2answers
38 views

How is PATH set for users in puppet?

I'm having an interesting problem which I was able to work around by manually specifying PATH. The problem is that although my root user's PATH is: ...
1
vote
0answers
75 views

Inherit environment variables in systemd Docker container

I have a Docker container running systemd. I want to pass environment variables to applications under it. When I start systemd from within Docker (/sbin/init as command line), Docker exposes ...
19
votes
2answers
825 views

Does ~ always equal $HOME

I know this has probably been asked before, but I couldn't find it with Google. Given Linux Kernel No configurations that change $HOME bash Will ~ == $HOME be true?
5
votes
3answers
131 views

Run program with environment set to variables in a file

I would like to run a program (in this case Python) with only the environment variables defined in a file, say vars.env: FOO=bar X=12 Here's a simply Python script that prints the environment: ...
4
votes
1answer
146 views

Keep getting the same result after “export PATH”

I am doing this: $ which cabal /usr/bin/cabal $ export PATH=$PATH:$HOME/.cabal/bin $ which cabal /usr/bin/cabal I expect to get /.cabal/bin/cabal for $ which cabal (this path exists) after this. ...
2
votes
1answer
52 views

How can I find where LANG, LANGUAGE and MAIL environmental variables are set?

I've had a few issues with environmental variables not set correctly in my Raspbmc Raspberry Pi. Specifically, I've had to manually specify the following in ~/.bashrc. export LANG='en_AU.UTF-8" ...
2
votes
0answers
89 views

Reading from /etc/environment with sudo

Using Ubuntu 14.04 LTS, I'm having a problem trying to read environment variables from /etc/environment when using sudo env. Basically, they are not being displayed. When I do just env, these ...
12
votes
3answers
317 views

Using variables to store terminal color codes for PS1?

In my .bashrc, I use ANSI terminal color codes to colorize various bits. It looks like this: PS1='\u@\h:\w\[\033[33m\]$(virtual_env)\[\033[32m\]$(git_branch)\[\033[0m\]$ ' where virtual_env and ...
14
votes
2answers
411 views

How do I start all shell sessions in a directory other than $HOME?

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 ...
0
votes
2answers
57 views

Why do I have to execute bash programs with ./? [duplicate]

Why is it that some bash programs will only run on my system when I type ./ before their name? An example: In my [...]/android/sdk folders I have to execute adb like this: ./adb devices Why not ...
3
votes
3answers
147 views

Messed up bash.bashrc file, commands not working anymore

Trying installing Java, I tried to add it to the executable path with the line: export PATH=/usr/lib/jvm/jdk1.7.0_60/bin:$PATH in the system-wide /etc/bash.bashrc file. For some reason this ...
2
votes
1answer
143 views

Bash script for running python virtual environment does not execute

I am trying to wrap the following call into a script, which runs my Python virtual environment: [lucas@lucas-ThinkPad-W520]/home/lucas/bin$ source ...
1
vote
0answers
22 views

Programmatically obtain LILYPOND_DATADIR for execlp() call

I wrote an application that calls lilypond by execlp()ing it. However, when my app executes this line, the following error occurs: GNU LilyPond 2.16.2 warning: not relocating, no 2.16.2/ or current/ ...
8
votes
4answers
116 views

Save output of command that modifies environment into a variable

How to save output of a command that modifies environment into a variable? I'm using bash shell. Assume that I have: function f () { a=3; b=4 ; echo "`date`: $a $b"; } And now, I can use commands ...
1
vote
1answer
35 views

Multiple MODULEPATH entries in .modulesbeginenv

I'm switching between paths/code projects. At each place I have different modules. To handle this there is a setup script that modifies what to use. This is handled with the tool 'module'. NOTE: ...
0
votes
0answers
30 views

Parameters files, pfiles director: how to overwrite default settings

This is a quite general question that I am not sure to be able to address correctly. I must manage some bash or tcsh scripts that invoke other software's tools. These tools are invoked by name and ...
4
votes
1answer
161 views

how to set environment variables from a shell script? [duplicate]

I'm trying to set environment variable through a shell script. Here is the script with various techniques: #!/bin/sh echo "export SOMEPATH=/root/some" >> /root/.bash_profile echo "export ...
5
votes
2answers
181 views

if statement in .bashrc not working correctly

I set up .bashrc to show a long prompt if the terminal is at least 80 characters wide. Otherwise it shows a degraded, smaller prompt. I use an if statement to achieve this: dp_smaller_than=80 if [ ...
2
votes
1answer
49 views

What does the period indicate when an environmental variable is set like “VARIABLE_NAME=.”

What does the period indicate when an environmental variable is set like VARIABLE_NAME=.
5
votes
3answers
323 views

Is there any harm in using variables that aren't set?

Say I have the following code: # Check if the color prompt is enabled and supported on this system if [ -n "$force_color_prompt" ] && [ -x /usr/bin/tput ] && tput setaf 1 ...
1
vote
2answers
54 views

How to guarantee availability of $BASH_ENV

A non-interactive, non-login shell will try to source any script specified in $BASH_ENV. But how do I guarantee $BASH_ENV is set before a cron job or script has a chance to set $BASH_ENV for any ...
1
vote
2answers
190 views

Setting PATH vs. exporting PATH in ~/.bash_profile [duplicate]

What's the difference and which is better to use when customizing my bash profile? Documentation on the export command is scarce, as it's a builtin cmd. Excerpt from version 1 of my ~/.bash_profile: ...
2
votes
0answers
12 views

Why does xdg-open text_file differ from sudo -u me xdg-open text_file?

If I run the following command, the text file opens in my preferred editor (kate). $ xdg-open text_file However, if I try the following, where sparhawk is my username, I get several warnings, and ...
5
votes
1answer
69 views

What else can break if I remove export from a variable?

My problem is that when I started coding my script I encountered several variable scope issues which resulted in the bad habit of exporting almost all my variables. Now that my code has got quite ...
3
votes
4answers
83 views

Protected environment variables?

Are there names of environment variables that cannot be overwritten by the user/a call to setenv? As I understand from POSIX1.2008, any process may edit the environment block, but must avoid ...
1
vote
2answers
271 views

How do I get a variable's value from one script and import it in another script?

How do I get a variable's value from one script and import it in another script? But the catch is that the script where I am going to get the variable's value has also some commands that I don't want ...
4
votes
3answers
176 views

Environment variables are not set when my function is called in a pipeline

I have the following recursive function to set environment variables: function par_set { PAR=$1 VAL=$2 if [ "" != "$1" ] then export ${PAR}=${VAL} echo ${PAR}=${VAL} shift ...
2
votes
4answers
147 views

How do I pass a variable from my local server to a remote server?

I am trying to pass a variable from my local server (location1) to a remote server (location2). The purpose of the code is to copy a file from the remote server from a predefined location. In simpler ...
1
vote
1answer
23 views

Sourcing scripts with a for loop for different variables

I have several shell scripts that I summarised within a global script. I am using some variables that are the same across all scripts, and I wrote a separate script for this, which I am sourcing in ...
21
votes
3answers
760 views

If processes inherit the parent's environment, why do we need export?

I read here that the purpose of export in a shell is to make the variable available to sub-processes started from the shell. However, I have also read here and here that "Processes inherit their ...
3
votes
1answer
92 views

Difference between “.” and “./” while setting the environment variables using export? [duplicate]

Please excuse me if I am not clear while asking questions. I will try my best to be very clear while asking questions. While learning Embedded Linux, we are setting an environment for our project. ...
1
vote
0answers
60 views

Create global enviromental variable after boot

I know about /etc/profile and /etc/environment, but I would like to set a global environmental variable after boot and login. By global, I mean an environment variable that can be accessed by any ...
1
vote
2answers
136 views

Variable value is not recognized after using gnu parallel?

I have a below shell script from which I am trying to copy 5 files in parallel. I am running my below shell script on machineA which tries to copy the file from machineB and machineC. If the file is ...
2
votes
2answers
59 views

What environment and credential is used by startup, background and service processes

Startup scripts (on boot) Processes running in (or sent to) the background (when using SSH -fN for example) Services etc... What $path variable will they be using? What credentials? Anything else I ...
18
votes
5answers
1k views

why is setting a variable before a command legal in bash?

I've just encountered several answers such as to parsing a delimited text file... that use the construct: while IFS=, read xx yy zz;do echo $xx $yy $zz done < input_file where the IFS ...
4
votes
1answer
108 views

System environment variables not appearing in sudo

I have the following line my /etc/environment file: BROKER_URL=tcp://xxx.30.8.163:61616 I run this and get: $ set|grep BROKER_URL BROKER_URL=tcp://xxx.30.8.163:61616 Then, I run: $ sudo bash # ...
17
votes
7answers
635 views

How do I source another process's environment variables?

If I examine /proc/1/environ I can see a null-byte-delimited string of process 1's environment variables. I'd like to bring these variables into my current environment. Is there an easy way to do ...
3
votes
1answer
115 views

Set environment inside `nsenter /bin/bash`

I'm entering a namespace with nsenter -m -u -i -n -p -t $PID /bin/bash. However, printenv inside this namespace doesn't have everything I need. I'd like to send these variables in, but I'd like to ...
3
votes
2answers
69 views

184 environment variables too many?

I am trying to find the cause of some OS wonkiness, and am concerned about environment variables. The software I have been handed puts an incredibly high amount of environment variables into the ...
1
vote
1answer
113 views

Is the $HOME environment variable always set on a Linux system?

Assuming the machine is running a Linux kernel, sessions make use of the Bash shell and everything is using default configurations (no user has made any changes to config files), can we assume that ...
2
votes
2answers
158 views

What is the difference between env and printenv?

What is the difference between these two commands (env, printenv), which both shows the environment variables? They output same contents by default except '_'. And any historical reasons for two ...
6
votes
3answers
286 views

Understanding environmental variables in different contexts

Trying to understand the behaviour of the environment in Linux (Ubuntu 13.04 concretely), I've find different situations where setting envirionment variables are used or defined for/in different ...
1
vote
0answers
45 views

Setting environment variables at runtime in KDE4

Is it possible to set an environment variable at runtime, affecting all the programs started from the DE after that point (Desktop Environment, in my case KDE4) (without rebooting)? I know it it ...
0
votes
2answers
75 views

How can I ensure that a custom environment variable is set before cron runs a task?

I recently experienced a logwatch issue that is fixed by running export DATE_MANIP=DM5. cron seems to forget this when I logout (presumably because it's not saved). Where can I add this custom ...
2
votes
4answers
611 views

bash script and local env variable namespace collision

I have a bash script with a variable called VAR_A I also have a local env variable called VAR_A The bash script calls the command: echo ${VAR_A} I am not able to change the variable in the script ...
1
vote
1answer
291 views

How can I set up environmental variables for www-data?

I asked a question on dba.se about how I can give my Perl CGI script the password it needs to access the MySQL database it needs to query. I have received only one answer but that one suggests I save ...
2
votes
3answers
137 views

setting environment variable as a function of another env variable [duplicate]

I would like to set an environment variable (that we'll call "TEST") to store the path to a sub-directory of my home directory : something like /home/myself/dir/. I would like to use the $HOME ...
2
votes
2answers
112 views

What does `env COLUMNS=%S ps …` do?

I have seen the syntax env COLUMNS=%sin shell scripts, e.g. see the line below from the Helm package in Emacs: env COLUMNS=%s ps -axo pid,user,pri,nice,ucomm,tty,start,vsz,%%cpu,%%mem,etime,command ...
4
votes
3answers
110 views

Why does export -p exclude $_ variable?

As far I know, there are 3 ways to see exported variables: $ export -p | wc -l 50 $ env | wc -l 51 $ printenv | wc -l 51 As you can see, export -p misses single variable. It's a $_ one: $ diff ...