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 votes
2 answers
37 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
10 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
92 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
34 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
463 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,278
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
  • 1
0 votes
0 answers
41 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
76 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
132 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
1 answer
188 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
  • 819
1 vote
1 answer
150 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
  • 1,954
0 votes
2 answers
65 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
74 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
49 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
80 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
  • 537
0 votes
1 answer
281 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
69 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
60 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
52 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
44 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
38 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
149 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
  • 11
0 votes
1 answer
74 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
106 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
126 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
64 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
3 votes
2 answers
338 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
48 views

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

What the Zsh equivalent of Bash's ${DIRSTACK[@]} variable?
user avatar
0 votes
1 answer
212 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
  • 29.6k
2 votes
1 answer
233 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
410 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
  • 849
0 votes
1 answer
287 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
210 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
152 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
350 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
65 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
111 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
3 votes
1 answer
318 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
  • 171
0 votes
1 answer
111 views

How to keep all environmental variables during sudo?

I am trying to use sudo -u postgres to run all postgresql commands inside a container and I'd like to inherit all environment variables before the sudo. I need to sudo in the first place because some ...
tinlyx's user avatar
  • 618
0 votes
2 answers
228 views

Variable content lost after while-done loop in a script finishes [duplicate]

I like to make global variables for all my host names. The must get an variable name ip_ = ipadress I got it working partially... The variable is lost out of the while done loop #!/bin/bash #file x.x ...
pvk's user avatar
  • 5
-3 votes
2 answers
351 views

Bash Script - Expand ESCAPED dollar-sign ($) into its Variable

My Problem I have this run.sh script: #!/bin/bash TODAY=$(date) FILE="my_file.txt.\${TODAY}" When I echo FILE I get this: echo ${FILE} Output: `my_file.txt.${TODAY}` But I want this: ...
Pixelbog's user avatar
  • 661
-2 votes
1 answer
48 views

Bash and Environment Variables

I have a number of bash scripts that use the following variables. Would it make sense to include them an Environment Variables? If so, how can I declare them properly? wht="$( tput bold; tput ...
Vera's user avatar
  • 1,183
0 votes
0 answers
155 views

Script for awscli check not working with crontab schedule

I have written a small code snippet to check the aws cli version #!/usr/bin/env bash if [ -e "/usr/local/bin/aws" ]; then myAWS="/usr/local/bin/aws" else ...
AashkaTe's user avatar
0 votes
2 answers
350 views

Command substitution not working with environment variable

I have this command which I want to variabilize. Particularly I want the latest argument presence to depend on an environment variable. ansible-playbook --inventory inventories/ssg-dev deploy.yml --...
Guerric P's user avatar
  • 103
1 vote
0 answers
225 views

Docker does not trigger login or invoke /etc/profiles?

Trying to deal with the problem of dircolors: no SHELL environment variable, and no shell type option given when I start my docker container. So from What sets the $SHELL environment variable? it can ...
xpt's user avatar
  • 1,344
0 votes
5 answers
438 views

How to start ssh-agent without eval

What I already know To start ssh-agent you need to use the command eval $(ssh-agent) You have to do this because of security reasons. A child process can't change environment variables of the process ...
Pixelbog's user avatar
  • 661
0 votes
1 answer
96 views

Conventions for the PATH variable's value

I am looking for best practices, or at least conventions, for the PATH variable's value. In particular, I would like to know is there any preferred/recommended ordering for the /bin, /usr/bin, and /...
kjo's user avatar
  • 15k
0 votes
0 answers
29 views

Manage PATH and other environmental variable centrally in Unix/Linux?

In windows, we can make a window pop up in control panel to edit environmental variables. That includes PATH. Then at all places we can use programs in PATH. However, in macOS, linux, etc, we add ...
Ma Joad's user avatar
  • 111
-1 votes
3 answers
782 views

Understand PS1 environment variable

On Stackoverflow, I just saw a question concerning the PS1 environment variable, which is responsible for the Linux terminal prompt. My prompt looks as follows: username@PORT-usr:/dir username is the ...
Dominique's user avatar
  • 141

1
2 3 4 5
31