Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [environment-variables]

A set of dynamic variables that can affect the running processes behavior and access to resources.

0
votes
1answer
73 views

How to debug the Networkmanager-dispatcher-variables

I want to debug a script that contains Networkmanager-dispacher-variables like DEVICE_IFACE, IP4_GATEWAY. The Networkmanager-manual describes these variables but doesn't mention how to debug them. I ...
0
votes
1answer
4k views

/etc/environment: /root: Permission denied

Whenever I run apt install to install a package it fails. I get this output at the bottom. It seems to go fine until it asks for permission ([y/n]) then is immediately followed by this output, ...
0
votes
2answers
23 views

creating OS environment variables using ExecStartPre on Systemd

I have the following unit file: [Unit] Description=Panel for Systemd Services After=network.target [Service] User=pysd Group=pysd PermissionsStartOnly=true WorkingDirectory=/opt/pysd ExecStartPre=/...
42
votes
5answers
3k views

What exactly is an environment variable?

I know that VARIABLE=value creates an environment variable, and export VARIABLE=value makes it available to processes created by the current shell. env shows the current environment variables, but ...
3
votes
4answers
986 views

Change prompt when starting a terminal from bash script (but don't affect all terminals)

I have two terminals installed, gnome-terminal and xfce4-terminal. I would like to have only the xfce terminal showing a simple > as prompt when I start it. The gnome-terminal prompt should remain ...
1
vote
1answer
2k views

Uninstall Android Studio + SDK

I am using linux arch. I installed android according to ArchWiki. I uninstalled every skd component and android studio using pacman -Rs. Also, I removed every hidden folder in the home directory that ...
4
votes
5answers
6k 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 ...
37
votes
7answers
96k 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?
2
votes
1answer
578 views

Preserve OLDPWD after logging out

I often need to go to the directory I was when I logged out of a server. I habitually use cd - for this purpose. However, after logging out and logging back in this does not work because apparently ...
3
votes
2answers
2k views

How to change environment variables without re-logging to UI?

How can I change environment variables without re-logging to UI? I want to re/define some variables and want them set on my current logged in shell (including UI). I know logging out and then logging ...
0
votes
3answers
58 views

I want to unset a list of bash variables that have their variable strings stored in an array

I'm working through creating a Dockerfile that calls on a script named start.sh I want to take the environment variables that are passed from the user either by means of docker-compose.yml or docker ...
12
votes
2answers
56k views

How to find where is $JAVA_HOME set? [duplicate]

I'm trying to change the value of $JAVA_HOME & I just can't seem to find in which file is it being set currently. I can't remember where did I set it the last time. Already tried How to determine ...
6
votes
1answer
14k views

How to pass environment variables to a non-interactive shell (with example)?

In a sh script another sh script is started with su -l <user> -c /path/to/script.sh. As far as I understood script.sh will be run in a non-interactive shell. The official documentation tries to ...
0
votes
1answer
2k views

Can't use latest youtube-dl outside the install folder

I recently installed youtube-dl from github: https://github.com/rg3/youtube-dl It works if I run it inside the install folder, like this: $ cd /home/max/software/youtube-dl $ bin/youtube-dl <url&...
0
votes
0answers
33 views

Knowing what directory a process started in

I'd like to be able to know mid-working what directory a child process started in. Here I'm in a Bash session, I start a dash session and I'd like to know where did dash start (in the example it ...
1
vote
0answers
30 views

Ruby script is not picking up sourced env vars

I am using environment variables in a Ruby script. When I export the variables and run the script as follows, it works fine. export ELK_URL="https://localhost:3241" ruby ./my_script.rb The contents ...
0
votes
1answer
84 views

$EDITOR environment variable won't set

Whenever I attempt to set the EDITOR environment variable, a subsequent check reveals no value has been set. I was attempting to edit the crontab: sudo crontab -e -u mycooluser which returns: no ...
0
votes
0answers
11 views

Gnome3 Session Startup File

What is the location of the "Gnome3 Session Startup File". I use Ubuntu 18.04 with gdm3 as display manager. I want to export an environment variable (persistent) for GUI (desktop) application. Also,...
17
votes
2answers
8k views

change environment of a running process

How might it be possible to alter some variable in the env of an already running process, for example through /proc/PID/environ? That "file" is read-only. Need to change or unset the DISPLAY variable ...
23
votes
6answers
5k views

Multiple arguments in shebang

I am wondering whether there is a general way of passing multiple options to an executable via the shebang line (#!). I use NixOS, and the first part of the shebang in any script I write is usually /...
20
votes
2answers
36k views

How to reset a shell environment?

This issue has been bugging me for a while, and although I've thought I've found my answer through EnvWatcher, unfortunately it only works on Bash. And I use zsh. I would like to replicate the things ...
1
vote
1answer
36 views

RedHat/Centos6.5 Environmental Variables Set on Startup - but from where? [duplicate]

I using Redhat/Centos 6.5. I am starting up the system and it already has environment variables set and is already running processes when it starts up. My questions: Where do these environment ...
7
votes
4answers
24k views

I have an environment variable for LANG set in ~/.profile but it is not getting set

I want to set the locale. I have this in my ~/.profile #language export LANG=en_GB.utf8 export TESTING123=en_GB.utf8 But when I type: echo $LANG $TESTING123 I get (LANG not set, but TESTING123 is ...
2
votes
2answers
1k views

How to source correct startup scripts on interactive, non-login shell

I'm trying to set up a sane/usable environment in a barebones OpenSolaris-derivative (OmniOS, a distribution of Illumos/OpenIndiana). I have all the plumbing code I need in .profile, .inputrc, and ....
102
votes
4answers
29k views

Is there a “.bashrc” equivalent file read by all shells?

Is ~/.bashrc the only place to specify user specific environment variables, aliases, modifications to PATH variable, etc? I ask because it seems that ~/.bashrc seems to be bash-only, but other ...
0
votes
1answer
946 views

When root, source another user's ~/.bashrc and get all environment variables

I'm trying to develop a small system app that is run as root. In this app, I would like to list all environment variables of the default user (not the $USER, but the user who calls runs the app as ...
2
votes
1answer
883 views

Executing commands with PHP: using normal user, but its home directory is /root

I'm using a custom compiled installation of Apache + PHP, listening on port 80. Apache is configured to run as a normal user, with the proper settings User and Group of the httpd.conf file. After ...
2
votes
1answer
947 views

Environment Variables not getting set in bash_profile

I have my bash_profile environment setting as follows: if [ `hostname` = "devoraebs01" ]; then echo `hostname -f` . /appl_top/deverp/appl/APPSDEVERP_devoraebs01.env When I log into this host, ...
0
votes
1answer
28 views

How to view the binary contents of environment variables?

I'm practicing CTFs (capture-the-flag) and want to view the contents of an environment variable: MyEnv=`python3 -c 'print(64*"A"+"\x0a\x09\x0a\x0d",end="")'` Now, hexdump displays the following, ...
0
votes
1answer
41 views

Debian Linux - Setting an environment variable for all users

I added the following in /etc/profile so that all my users can see the path export JAVA_HOME=/opt/jdk11 export PATH=$PATH:$JAVA_HOME/bin But after restarting my laptop, I cannot see the changes ...
5
votes
5answers
5k views

Is there a CLI tool that would prettify a JSON string

On my host I enter the following, which returns a bunch of information which isn't particularly easy to read at the CLI. echo $ENV_VAR | base64 --decode Is there a way to format it? This is a ...
0
votes
1answer
13 views

how does the expression b=${b:-“/data”} work [duplicate]

I've run a cross a shell script with BUILDDIR=${BUILDDIR:-"/data"} which , upon experimentation, takes the original BUILDDIR if it exists and isnt an empty string, and otherwise sets it to /data. What ...
18
votes
5answers
31k views

Prevent SSH client passing TERM environment variable to server?

I'm currently using Fedora 18 gnome-terminal, then started tmux multiplexer in it. After I connected to a CentOS 5 server via ssh command, I find: ls result has no color tmux, screen, hexedit, htop ...
33
votes
3answers
52k views

Exporting a variable with dot (.) in it

How to export a variable which has dot in it. I get 'invalid variable name' when I tried : export my.home=/tmp/someDir -ksh: my.home=/tmp/someDir: invalid variable name Even escaping metacharacter ...
8
votes
2answers
2k views

Unset all ENV variables matching _PROXY

I'm trying to unset all environment variables that match _PROXY: env | grep -i _proxy | column -t -s '=' | awk '{ print $1 }' | grep -iv 'no_proxy' | xargs -0 -I variable unset variable but it's ...
5
votes
3answers
946 views

Equivalent to “source” in OpenBSD?

Trying to open a python3 virtual environment I have created with python3 -m venv myVenv by doing source myVenv/bin/activate as I do in Linux, but I get ksh: source: not found which mean it is ...
3
votes
3answers
3k views

Set environment variable for subshell

I know that I can run a command with an environment variable like this: FOO=bar mycommand I know that I can run commands in a subshell like this: (firstcommand && secondcommand) But can I ...
8
votes
2answers
2k views

Indirectly expand variables in shell

I need to indirectly reference a variable in the bash shell. I basically want to what you can do in make by writing $($(var)). I have tried using ${$var} which would be the most straight forward ...
0
votes
0answers
1k views

Setting environment variable for apache user

I tried what not: in /etc/profile.d/ I created a script file apachhe.sh with content if [ $UID -eq 48 ]; then . export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH; fi in /etc/environment I added ...
6
votes
2answers
8k views

Checking if PATH contains $HOME/mydir and adding it if not (all in a script) [duplicate]

Possible Duplicate: keep duplicates out of $PATH on source Some of my scripts are located in $HOME/mydir. Unfortunately, they are not accessible from elsewhere if this dir is not part of PATH. I ...
135
votes
9answers
92k views

How to determine where an environment variable came from?

I have a Linux instance that I set up some time ago. When I fire it up and log in as root there are some environment variables that I set up but I can't remember or find where they came from. I've ...
0
votes
1answer
63 views

How do I use ssh-agent as a wrapper program?

I'm trying to start awesome windows manager as a subprocess of ssh-agent. It worked when I used startx (ssh-agent startx). But now I'm trying to make it work under lightdm. lightdm starts /usr/bin/...
845
votes
11answers
2.0m views

How to correctly add a path to PATH?

I'm wondering where a new path has to be added to the PATH environment variable. I know this can be accomplished by editing .bashrc (for example), but it's not clear how to do this. This way: export ...
1
vote
2answers
69 views

Bash environment variables in non interactive mode

I'm trying to define environment variable for non-interactive console in Raspbian. In theory I need to add the varaibles to ~/.bashrc or ~/.profile or /etc/bash.bashrc or /etc/profile. For example I ...
3
votes
1answer
668 views

Running a constructed command from bash script

I constructed a command like this in a bash script a="my_cmd"; a="$a --verbose"; echo $a; $a; It works and executes my command correctly. But when I add an environment variable to the mix it breaks. ...
4
votes
1answer
5k views

Which file defines the LESSOPEN environment variable?

On my Linux machine - I do the following: $ env | grep -i LESSOPEN LESSOPEN=|/usr/bin/lesspipe.sh %s So from env command I see that: LESSOPEN=|/usr/bin/lesspipe.sh %s I want to change the variable ...
34
votes
4answers
179k views

“not a valid identifier” when I do “export $PATH”

When I run export $PATH in bash, I get the error not a valid identifier. Why?
77
votes
4answers
81k 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 ...
4
votes
5answers
2k views

Is there a nice way to set directory/project local environment variables?

I have been working on several projects, and they require different environment variables (e.g., PATH for different versions of clang executables, PYTHONPATH for several external modules). Whenever I ...
4
votes
2answers
2k views

shell functions and variables with the same name

From Bash Manual: Note that shell functions and variables with the same name may result in multiple identically-named entries in the environment passed to the shell’s children. Care ...