Questions tagged [environment-variables]

For questions pertaining to environment variables, a set of dynamic variables that can affect the running processes behavior and access to resources. Use this tag for questions about environment variables or questions about issues arising from the impact of setting or modifying the variables value in running processes behavior and access to resources.

Filter by
Sorted by
Tagged with
1 vote
0 answers
36 views

Why am I using an interactive non login shell, but I can still access the environment variables defined in /etc/profile?

According to the bash manual,only login shell will load the /etc/profile file. When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first ...
hhx's user avatar
  • 11
0 votes
0 answers
60 views

"Run dialog" BOX is not recognizing custom commands

I completely switched to linux a week ago, I modified my windows to run commands on "Execute" box (WIN + R) and thats VERY handy, for such things like open folders in specific locations, ...
wido's user avatar
  • 1
0 votes
1 answer
43 views

LINENO and BASH_LINENO

So I'm not sure why this is.. I know ${LINENO} normally contains the line in the script, and BASH_LINENO goes based on input from BASH_SOURCE as an array $ (echo hi;declare -p LINENO BASH_LINENO;echo ...
linuxgeek's user avatar
-1 votes
1 answer
46 views

Can I change the text insertion icon system-wide?

System-wide, I desperately want to make my text-selection icon a cross-hair. It might have been a huge laugh decades ago, choosing an oversize capital (upper-case) letter I for Insert (geddit?), but ...
Phil Headford's user avatar
0 votes
0 answers
25 views

unsetting env. variable before a command [duplicate]

In my zsh I have set the environment variable PAGER to less. However in mercurial this environment variable takes precedence over specifying a pager in its config file and I ultimately want a ...
Anthon's user avatar
  • 79.1k
-1 votes
2 answers
110 views

How to set one-command-lifelong variables in the shell? [duplicate]

Consider the following example: file="test" echo $file My idea is that file persists only during the command echo $file. Although $file does not persist after this command, echo prints ...
Rubem Pacelli's user avatar
0 votes
1 answer
59 views

Is there an env var 'SSH_PWD', and how do I use it to restore my last 'pwd' prior to logout?

The lab has several "Raspberry Pi" machines which run a Debian-flavor OS. They are used for specific purposes - which is to say that after I make an SSH connection, I cd to the folder where &...
Seamus's user avatar
  • 2,885
0 votes
0 answers
30 views

Scope of environment variables

I had thought previously, that environment variables are defined at process scope, and if exported, are propagated to child processes as well. So, I wanted to find a single place to define my ...
Eugene Shtoka's user avatar
2 votes
2 answers
247 views

How do I use environment variables from file in systemd

I set environment variables in some file /etc/profile.d/mercure.sh like this : export MERCURE_PUBLISHER_JWT_KEY=$(cat /home/stephane/mercure/publisher.key.pub) export MERCURE_PUBLISHER_JWT_ALG=RS256 ...
Astro-Otter's user avatar
0 votes
2 answers
63 views

bash var substitution inside json to use in curl

Team, I am unable to substitute values inside json(myjson) to use in curl command. any hint? JENKINS_USERNAME="svc-user" JENKINS_USER_TOKEN="xxxx" JENKINS_INSTANCE_FQDN="sham....
AhmFM's user avatar
  • 125
0 votes
1 answer
74 views

Which binary is used (per specification) if there are multiple ones with the same name at different locations in PATH?

If two different directories in the PATH environment variable both contain a binary with the same name (but slightly different behavior), are there specifications/guarantees on which one will be used? ...
Matteo's user avatar
  • 73
-1 votes
2 answers
85 views

How to prepend a prefix to variables sourced from a config/env file

I have this situation: source local.env run_my_app In local.env, I have a bunch of environment variabless that pertain specifically to run_my_app, like this: es_protocol="http" es_host=0.0....
Alexander Mills's user avatar
0 votes
0 answers
34 views

Set proxy on login if proxy server is reachable

I have to move between work, where we have a firewall and have to connect to the internet through a proxy and home where I do not need a proxy. Since there are no global proxy settings in Linux and a ...
Oskar's user avatar
  • 101
-6 votes
1 answer
116 views

What is the `COLOR` environment variable? [closed]

What is the history behind $COLOR, why is no one using it, is it safe to use, and what should it be used for. Why is it COLOR="1" on my "Windows Subsystem for Linux v2 Debian VM"? ...
Junaga's user avatar
  • 379
0 votes
1 answer
88 views

Set PATH for /bin/sh in Debian:11 image

Background I am building an image based on Debian:11. I am trying to set the PATH for the /bin/sh with a dynamic value determined at image build-time. (The "at image build time" is important....
Wallace Kelly's user avatar
4 votes
3 answers
675 views

Safely save and restore environment variables

I have a script that parses a rudimentary .env file and exports its contents as environment variables, before taking further action: set -eu test -f .env && load_dotenv exec ./foobar x y z &...
shadowtalker's user avatar
  • 1,318
0 votes
0 answers
37 views

How to set dotenv variables in bash shell when changing directory? [duplicate]

I'm trying to set custom environment variables when changing to a particular directory that has a .env file containing the variables. In order for it to be triggered automatically, I included the ...
Marin's user avatar
  • 101
0 votes
0 answers
62 views

How do you pass an array through systemd EnvironmentFile?

[root@vm-devcjn-01-a tmp]# cat /tmp/test_service_script_fred #!/bin/bash sleep 30& echo `date` $# args: $@ > $0.log When called from the shell, passing an array, works as expected: [root@vm-...
Chris's user avatar
  • 1
1 vote
0 answers
137 views

Use env var in the path section of LoadCredential of systemd unit file

I am creating a service that I want to run under Ubuntu using systemd. For this service I need to load a credential using the LoadCredential= option of systemd. This works with the following unit file ...
Rasmus B. Sorensen's user avatar
0 votes
1 answer
210 views

Add remote server path to environment variable

A very (I thought) simple question, but cannot find an answer: In Bash: Is it possible to add the path to a remote server to an environment variable? Use case: We are setting up a local pip repo and ...
s3dev's user avatar
  • 205
1 vote
2 answers
299 views

How to export global variables to child process in bash

I am using Arch and bash and Openbox window manager. Everything is up to date. Openbox is configured with a file called rc.xml Within rc.xml I typically call bash -c 'command1; command2; etc' to ...
Kes's user avatar
  • 829
1 vote
1 answer
159 views

some_variable vs some-variable in zsh

Why is it that zsh seems to understand what to do with some_variable=1 command, but not some-variable=1 command? E.g.: $ fs_screen=1 mpv --fs-screen=${fs_screen} someFile.mp4 works fine but $ fs-...
Harv's user avatar
  • 2,004
0 votes
2 answers
70 views

how to make a subshell a "program"

I want to ignore all pre-existing env variables, and echo just one, like this: env -i <( export foo=bar; env ) and this would just print: foo=bar however, the construct of env -i <() ...
Alexander Mills's user avatar
0 votes
1 answer
157 views

diffing two .env files

I have two env files, let's say x.env and y.env, the order of the variables is different, but the content could be the same but likely different. Is there some tool I could use to diff the variables? ...
Alexander Mills's user avatar
0 votes
0 answers
117 views

Environment variable explicitly set on /etc/profile is lost on Arch

This was my /etc/profile before I modified it. $ cat /etc/profile # /etc/profile # Append "$1" to $PATH when not already in. # This function API is accessible to scripts in /etc/profile.d ...
du578110's user avatar
0 votes
1 answer
251 views

Why am I missing $XDG_RUNTIME_DIR and $DBUS_SESSION_BUS_ADDRESS after logging in via SSH and trying to set up user scope service

I'm trying to set up a user scope service after logging in via SSH, but when I try setting anything up like.. systemctl --user enable wallpaper.timer I get these errors, even though I'm logged in via ...
deanresin's user avatar
  • 547
0 votes
1 answer
482 views

Why the docker-compose.yml environment overrides the .env file content?

I have a docker container that is set up using docker-compose.yml and I introduce a couple of environment variables in it: environment: - AUTH_SECRET=some_secret Then I have these ...
Saeed Neamati's user avatar
0 votes
0 answers
111 views

Environment variables are not getting loaded when script is executed on a remote server via SSH (RHEL 8)

I have a vendor script (startup.sh) to start application services on a Linux box. Script when called manually by logging into the server (as sudo su - userID) initiates all the environment variables. ...
Akshay's user avatar
  • 15
1 vote
0 answers
82 views

How can daemons source environment variables on a machine without persistent storage

I'm working on a Yocto Project build of an AARCH64 system, where I need the monit daemon (or at least a process started by monit) to access an environment variable I'm setting. It's my understanding ...
Patrick M's user avatar
0 votes
0 answers
102 views

Use environment variables in terminator config

I want to launch terminator with multiple terminals with some starting on a different directory. The directories could change based on the $USER on different systems but I have them defined in .bashrc ...
silent_monk's user avatar
0 votes
0 answers
56 views

Bash script or the like to erase env values that host secrets once used to initialized app in a kubernetes container

I have a flask app that runs in a kube cluster. It does all the right things by using kube secrets to set the env values required to initialize the application. There are some env values I suspect ...
Edmund's Echo's user avatar
0 votes
0 answers
48 views

Automating proxy configuration across multiple applications without plaintext password

More generally than the post described here: Using bash functionality in rc files I would like to set an appropriate proxy configuration for all/multiple applications including but not limited to: ...
Sterling Butters's user avatar
3 votes
1 answer
271 views

`sudo --preserve-env=MY_VAR` vs `sudo env MY_VAR=$MY_VAR`

I read in man sudo the following: --preserve-env Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the ...
Doron Behar's user avatar
0 votes
1 answer
34 views

What are the differences in the way to get the value of a single environment variable? [duplicate]

I know the typical way is echo "$PATH", for example. But echo $PATH also works. Also, you don't need the echo command even, you can just type $PATH, and the value of path will be outputted ...
vw1262's user avatar
  • 19
0 votes
1 answer
84 views

Is it a good idea to put "export BASH_ENV=~/.bashrc" in my .bashrc?

Let's say my Bash has some extensive ~/.bashrc customization that aids me not only in interactive use, but also in scripting (aliases, functions, variables, etc.). I would like to have this available ...
Sebastian Carlos's user avatar
0 votes
2 answers
128 views

Pass a variable that contains a comma as a -v option to qsub

After seeing the reactions on Stack Overflow on this question and an unfamiliarity with qsub, I believe thqt U&L is better suited for this question. In qsub, we can pass environment variables (a ...
Bram Vanroy's user avatar
0 votes
1 answer
207 views

Why RStudio is not picking up environment variables defined in $HOME/.bashrc

I use Arch Linux. I use SSDM as display manager, but I have disabled it with: sudo systemctl disable sddm I have put code in /etc/profile, $HOME/.bash_profile and $HOME/.bashrc to echo when those ...
robertspierre's user avatar
0 votes
0 answers
84 views

Reading Environment variable in ebpf

I am trying to create an ebpf program in C and want to read user set environment variables. Something similar to getenv in C. I am unable to find a bpf_helper() function that does this job. Does there ...
kshh23's user avatar
  • 1
4 votes
2 answers
374 views

How to unset bash variable `!::=::\`? [duplicate]

When I run printenv one of the returned variables is !::=::\. I noticed that the variable exists because docker does not work correctly with it set. $ printenv | grep :: !::=::\ $ docker stack deploy ...
anderio Moga's user avatar
-3 votes
1 answer
50 views

Bash variable ${DIRSTACK[@]} for zsh [closed]

What the Zsh equivalent of Bash's ${DIRSTACK[@]} variable?
user avatar
1 vote
1 answer
372 views

What are these bash functions on Alma Linux 8 viewable in the environment with `env`?

When I run in env in Alma Linux 8, I get the following BASH_FUNC_which%%=() { ( alias; eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@ } ...
Evan Carroll's user avatar
  • 30.4k
2 votes
1 answer
291 views

Systemd unit file - set environment variable value based on conditional?

I was wondering if it's possible to set an environment variables value based off of a conditional inside the systemd unit file, specifically a service file. Ex: Environment=if (condition) { SOME_VAR=1}...
Guy's user avatar
  • 21
1 vote
1 answer
705 views

How to pass environment variables when executing command as another user?

As root I did # WWWFOLDER=myproject # echo $WWWFOLDER myproject # su - anothershelluser /bin/bash -c "echo $WWWFOLDER" # As you can see, I got nothing printed. I already tried, without ...
realtebo's user avatar
  • 917
0 votes
1 answer
369 views

execute script from another script not working [closed]

I am using shell scripts to compile the different components. I have one main script which is calling another shell script. Here is an example, Repo/build.sh Repo/code/mode/1/build/build_1.sh Now if ...
sagar's user avatar
  • 3
0 votes
1 answer
272 views

How time zone variable for Kubernetes should look like?

I am European export BOOTSTRAP_TIMEZONE="UTC +2" I can not check, something is wrong with Github right now. If that is not right what should I change?
Richard Rublev's user avatar
0 votes
0 answers
210 views

How to change default DISPLAY environment variable in RHEL8

I'm in a weird spot in which I'm trying to run an independent vnc server on display localhost:1, but given that I am running Gnome, that display is already being used by the desktop itself. I do not ...
Zack B's user avatar
  • 1
0 votes
0 answers
384 views

Use shell command to set env variable in Dockerfile

I am trying ot set up a custom redis alpine image and I would like to set the private IP that get assigned to the instance as an environment variable. In order to do so, I am using the following ...
user20656733's user avatar
0 votes
1 answer
80 views

How might I source a Bash script from another interactive Bash script?

I have a interactive Bash script, conozcoArrays.sh, #!/usr/bin/bash echo -e "\nGive me their phone number?\n" read number TOGOes=("$(find ~/chicas -maxdepth 1 -iname "*$number*&...
John Smith's user avatar
1 vote
3 answers
142 views

export command behaviour in bash vs bourne shell

bash v3.2 (though I think holds for newer versions too): In section 3.7.4 Environment, the docs say: On invocation, the shell scans its own environment and creates a parameter for each name found, ...
Ben Ldr's user avatar
  • 13
5 votes
1 answer
466 views

systemd $HOME environment variable different from expected

I have a service that runs as root: [Unit] Description=my service After=docker.service network-online.target Requires=docker.service network-online.target [Service] TimeoutStartSec=0 RestartSec=60 ...
Alex's user avatar
  • 201

1
2 3 4 5
31