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

learn more… | top users | synonyms

11
votes
3answers
5k views

How to read environment variables of a process

Linux's /proc/<pid>/environ does not update (as I understand it, the file contain the initial environment of the process). How can I read a process's current environment?
1
vote
2answers
310 views

What are the key differences between $ENV_VAR and `env_var`?

It's a quite simple asked question I think: What are the key differences between using environment variables just like $HOSTNAME and `hostname`. Where is which appropriate, why are there two ...
3
votes
2answers
2k views

Why isn't my environment variable visible from the command line?

I'm trying to run the James SMTP server on Lion (Mac OS X 10.7.2). When I do this: sudo JAVA_HOME=/Library/Java/Home ./james-2.3.2/bin/run.sh it works fine. However, I'd like to make JAVA_HOME an ...
2
votes
2answers
313 views

Is there a difference between setting an environment variable to the empty string and unsetting it?

Is there any practical difference between unsetting an environment variable and setting it to the empty string?
5
votes
2answers
1k views

Send a command to a running tmux session (like screen -X)

I'm looking to switch from screen to tmux for my terminal multiplexing needs, but there's a feature of screen that I need to replicate in tmux: the -X option, which allows one to run arbitrary screen ...
8
votes
4answers
6k views

What scopes can shell variables have?

I just ran into a problem that shows me I'm not clear on the scope of shell variables. I was trying to use bundle install, which is a Ruby command that uses the value of $GEM_HOME to do its work. I ...
2
votes
4answers
437 views

Update Linux Path permanently [duplicate]

Possible Duplicate: How do I set a user environment variable? (permanently, not session) How can I permanently modify the PATH variable in Ubuntu? Is it possible to do it without modifying ...
14
votes
6answers
22k views

How can I run a cron command with existing environmental variables?

How can I run a cron command with existing environmental variables? If I am at a shell prompt I can type echo $ORACLE_HOME and get a path. This is one of my environmental variables that gets set in ...
9
votes
4answers
6k views

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
4
votes
2answers
11k views

Refresh env variables after editing bashrc file

I frequently edited the .bashrc file to export new environment variables. Rather than close the console and start a new one to refresh the env variables, is there a convenient way to refresh?
2
votes
0answers
78 views

How to get environment variables to persist across login? [duplicate]

Possible Duplicate: How do I set a user environment variable? (permanently, not session) For a project I'm working on, I have a service that runs at startup which calls a script to set ...
2
votes
1answer
2k views

Why my $PATH is not inherited by the invoked bash?

I work on an AIX system where I have no administrator privileges. It has several shells installed, default being tcsh. I am not allowed to change the login shell. Usually I start my session from exec ...
5
votes
3answers
8k views

How to set global environment variables at boot through a script, and have them available for an application that runs before login?

I have a service that runs at boot, and in that service it calls a bash script in the background that exports some environment variables. The problem I'm having is that those environment variables ...
71
votes
4answers
111k views

How to correctly add a path to PATH?

I'm wondering where a new path has to be added to PATH environment variable. I know this is accomplished editing .bash_rc (for example), but it's not clear how to do this. This way: export ...
2
votes
1answer
156 views

Why does this variable have no value even though it is set in .bashrc?

If I append this: hi=11 export hi to the .bashrc and then I su to this user with: su - bela then I: echo $hi 11 Then it's working, the "hi" variable has the value of "11". But. When I: ...
0
votes
0answers
295 views

Why do you need sudo for “sudo su root”? [duplicate]

Possible Duplicate: When do su and sudo use different passwords? Why do you need to use sudo su root ? Why won't it work to just use su root?
6
votes
5answers
4k views

Run script in a non interactive shell?

I have a cron job that is running a script. When I run the script via an interactive shell (ssh'ed to bash) it works fine. When the script runs by itself via cron it fails. My guess is that it is ...
5
votes
2answers
3k views

How to get a clean environment in a ksh shell?

I need to get rid of all the environment variables in a Ksh shell. I can fork a new instance, but it will inevitably source some init files (as far as I know .profile, .kshrc). Is there a way to ...
3
votes
2answers
1k views

(G)VIM uses a different $PATH than my system

Because Ubuntu provides no up-to-date packages for TeXLive, I installed it manually. However, some programs need TeXLive as dependency. So what I did is I installed the TeXLive package from the Ubuntu ...
2
votes
2answers
276 views

Function to evaluate variables in BASH

Given a variable name is there a function that will print its value? Often times I pass the name of a variable to a bash function and instead of doing the expansion while passing it I would like to ...
6
votes
2answers
5k views

How to alter PATH within bash script?

I have several projects that require me to change versions of Java/Grails/Maven. I'm trying to handle this with some Bash scripts that would make the changes. For example: #!/bin/sh export ...
1
vote
1answer
152 views

How do I change the path used by the Gnome Command Line applet?

For my shell, I know that I have to modify .bashrc to add my ~/bin directory to the command path, but how do I get the Gnome Command Line applet to use that as a program location too? I'm using ...
5
votes
3answers
302 views

For a same unix or linux user, different sets of environment variables

I'm using tcsh, and for a specific project every member of my team connects to a server with the same user. (This is something we cannot change). The situation arises because I want to have some ...
1
vote
1answer
1k views

pass 1 environment variable using sudo

Is this a correct way for passing an environment variable in sudo ? sudo -u www-data -b env FOOBAR="foobar" /home/user/folder/daemon
0
votes
1answer
343 views

Variable assignment in .bash_profile has no effect

I added the following to my .bash_profile: JAVA_HOME=$JAVA_HOME:/usr/java/jdk1.7.0 export JAVA_HOME However, when I echo $JAVA_HOME it outputs an empty string. Why weren't my changes to ...
5
votes
4answers
953 views

Last failed command in bash

The $? variable holds the exit status of last run command. Is there a variable that holds last run command itself?
28
votes
5answers
71k views

How do I set a user environment variable? (permanently, not session)

This is irritating me. I seen several suggestions (all using different files and syntax) and none of them worked. How do I set an environment variable for a specific user? I am on debian squeeze. ...
6
votes
5answers
442 views

PATH environment variable in linux

I want to know how the standard environment variables given by the linux OS like PATH, HOME are set automatically. In which file are these read from. There should be some file from which these ...
4
votes
2answers
2k views

How to run a cronjob in my regular environment?

Both the shell and environment variables that cronjobs are run in is completely different from the ones presented to me in gnome-terminal. How can I run a cronjob under the same circumstances as if I ...
4
votes
3answers
147 views

How can I make a public variable in Linux that all users would see?

I need to have a variable $FOO on the system that contains a string all users could use, but I have no idea how to create one. The Upstart job is obviously not a solution as from this thread - Is it ...
4
votes
3answers
4k views

Is it possible to export env variable via Upstart?

I need to export a variable FOO=stringhere so that system processes could use it. And the place I would like to do this, is Upstart job. Unfortunately, I tried as per Upstart manual to do env ...
4
votes
3answers
306 views

Need help deciphering unix statement

I need help deciphering what is being said here: export IP=`/sbin/ifconfig | grep 'inet addr:'|grep -v '127.0.0.1'| cut -d: -f2 | awk '{print $1}'` I know it is to set IP as an environment ...
4
votes
2answers
136 views

Why do newlines mess up my while condition?

I have a while loop that allows setting variables when written one way but does not allow it when written another way. Why is that? This prints var as 1234 and does not print var2 #!/bin/bash ...
4
votes
2answers
604 views

In `while IFS= read..`, why does IFS have no effect?

I might have something absolutely wrong, but it looks convincing to me, that setting IFS as one of the commands in the pre-do/done list has absolutely no effect. The outer IFS (outside the while ...
31
votes
4answers
11k views

Why is `while IFS= read` used so often, instead of `IFS=; while read..`?

It seems that normal practice would put the setting of IFS outside the while loop in order to not repeat setting it for each iteration... Is this just a habitual "monkey see, monkey do" style, as it ...
2
votes
2answers
308 views

How do you set an environment variable?

Please explain how to set environment variables. I need to point an environment variable to a xml file.
2
votes
2answers
1k views

Tell pkg-config to look *.pc files also in /usr/local/lib/pkgconfig, system-wide

Right now pkg-config looks only in /usr/lib/pkgconfig. I can adjust it for a user by exporting the PKG_CONFIG_PATH environment variable, but once again I forgot to do it for root and wasted time ...
7
votes
1answer
867 views

Where have I set my bash PATH?

I want to remove ~/bin from my PATH.  I set it up months ago when Linux (Ubuntu) was very new to me, but I don't know how I added it... Nothing shows up when I search all the files listed below. ...
3
votes
3answers
627 views

Easy way to restore your MANPATH

I was attempting to add the man pages for my texlive distribution today when I accidentally did this: $ MANPATH=MANPATH:/usr/local/texlive/2011/texmf/doc/man $ export MANPATH ...when I meant this: ...
2
votes
2answers
1k views

Exception of inheritance of environment variables

Quoted from Wikipedia: By default, when a process is created it inherits a duplicate environment of its parent process, except for explicit changes made by the parent when it creates the ...
2
votes
3answers
287 views

Source (.) piped curl output

I have a file, f, on my webserver with the following contents: alias ll='ls -l' I would like to (from another linux box) do the following, but I can't get the command right: curl http://myserver/f ...
9
votes
2answers
3k views

What is the significance of single and double quotes in environment variables?

I defined some environment variables in my .profile like this: MY_HOME="/home/my_user" but the variable does not seem to evaluate unless I strip off the quotes and re-source the file. I believe ...
9
votes
4answers
5k views

What environment do I get with sudo?

When I run sudo, what exactly happens to my environment? When I run sudo command, it doesn't seem to see my or root's environment. For example, my path for both includes /usr/local/bin, but if I try ...
3
votes
2answers
166 views

Why first set a variable and then export it instead of setting and exporting in one command?

If gpg-agent is executed, it outputs data that can be processed by a shell directly, e.g.: SSH_AUTH_SOCK=/tmp/ssh-apeOFqMF3292/agent.3292; export SSH_AUTH_SOCK; SSH_AGENT_PID=3293; export ...
6
votes
1answer
1k views

using environment variables in tmux.conf files

Is it possible to use an environment variable in a tmux.conf file? I am trying to set a default-path to an environment variable. Currently what I am trying is: set -g default-path $MYVAR further I ...
6
votes
2answers
4k views

set LC_* but not LC_ALL

I'd like to have a German (Austria) locale (A4 paper size, 24 hour time, yyyy-mm-dd), but an English-language user interface (I don't like poor translations). I figured that the correct way to achieve ...
4
votes
1answer
2k views

dot file not sourced when running a command via ssh

When I run my program interactively, it works fine: ssh somehost $ ~/some/path/somescript.py When I run my program over ssh directly, it doesn't work. The variable PYTHONPATH is not set, because ...
2
votes
3answers
808 views

FIrefox/Thunderbird storage locations

By default, Firefox and Thunderbird save their files to ~/.mozilla and ~/.thunderbird. I am wondering if there's an environment variable I can set, to have either of them save their data to a ...
5
votes
2answers
493 views

Isn't $HOME supposed to be the location of the user's home directory?

I'm having trouble with a web application I'm writing: The web application, which runs as user nobody, needs to launch an inkscape process to manipulate some SVG files. Because this runs as user ...
3
votes
2answers
1k views

Is there a way to push shell config information when SSHing to a host?

I know how to set the GNOME-terminals (or xterms!) prompt to green/red regarding the last exit code: vi .bashrc export PROMPT_COMMAND='PS1="` if [[ \$? = "0" ]]; then echo "\\[\\033[0;32m\\]"; else ...