Skip to main content

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

I am following a video on setting up Qemu/KVM. Setting up of tuned, I am having a problem with missing parameters. How can I correct these errors?

In setting up Qemu and KVM: I received the following notification.  I have seen several others with this same problem, but I have not been able to find a post with a resolution to implement. $ sudo ...
fb0034's user avatar
  • 11
2 votes
1 answer
130 views

LD_DEBUG_OUTPUT does not work

touch /tmp/debug.log LD_DEBUG=all LD_DEBUG_OUTPUT=/tmp/debug.log ls After doing this I expect debug info to be written to the /tmp/debug.log file, but it is empty. Ubuntu 20.04
ibse's user avatar
  • 341
0 votes
1 answer
37 views

LD_PRELOAD variable from /etc/profile is not saved in the environment when running sudo --preserve-env

Added LD_PRELOAD variable to the end of /etc/profile: export LD_PRELOAD=/tmp/libhooks.so Then I start a new ssh session and there is a LD_PRELOAD variable in it: [admin@Centos8 ~]$ env | grep ...
ibse's user avatar
  • 341
-1 votes
0 answers
30 views

Secure way to store private key in toml file?

I have a config.toml file that requires inputting a private key as such: private_key = "< enter private key"> Is there a way to store the private key in a keystore and then uses a ...
LearnerSysAd's user avatar
13 votes
3 answers
1k views

Why does setting a variable readonly in the outer scope prevent defining a local variable with the same name?

I've found nothing about this in all my searching. In the code below, Bar1 acts like I'd expect a "regular" variable to act (since help declare says that -g is only "seen" in ...
RonJohn's user avatar
  • 1,144
3 votes
2 answers
295 views

how to alias the `history` function in fish shell

I'm trying to set the fish history pager to be bat -l fish for syntax highlighting. (i.e. set the PAGER environment variable bat -l fish just for the history command). I tried: # 1: alias history &...
matan h's user avatar
  • 147
1 vote
1 answer
59 views

How to store and source environment variables when they contain semicolon (`;`) [duplicate]

I'm trying to exchange environment variables and restore them quickly between terminals. I define two functions in my shell (~/.bashrc): save_env(){ mkdir -p ~/tmp printenv > ~/tmp/env } ...
furynerd's user avatar
1 vote
1 answer
27 views

Passing modprobe options through environment

man modprobe says in the ENVIRONMENT section: The MODPROBE_OPTIONS environment variable can also be used to pass arguments to modprobe. But this is unclear. Suppose for example that I want to force ...
q.undertow's user avatar
0 votes
1 answer
65 views

data json to env unix with jq

i have problem my command for me is working but the command export test=test not working in command with jq but if i run only export test=test it's working so i have file test.json inside : { "...
Mohamed N.'s user avatar
0 votes
1 answer
49 views

Guix: How to add an environment variable in a guix.scm file for use with guix shell? Or is it not possible?

guix shell allows users to create a shell and control what resources are available. How can I use the guix.scm file to specify an environment variable in this shell environment? In this specific ...
Daniel's user avatar
  • 688
0 votes
0 answers
31 views

Concatenating 2 environmental variables in a ksh script [duplicate]

I have a storage.src file with the following 2 environmental variables exported export FIRST="HelloHelloHello" export SECOND="World" I have a .sh file as follows #!/bin/ksh . /...
Devansh Mittal's user avatar
0 votes
1 answer
29 views

Cannot enable sound with bb even with pasuspender

For this problem, I had trouble with getting bb to work with pipewire. Executing the command pasuspender -- env PULSE_SERVER= bb returns Failure to suspend: No such entity. How do I enable bb with ...
horsey_guy's user avatar
1 vote
1 answer
66 views

Why is FPATH not listed in `env` output?

I'm running zsh (on MacOS) and I just learned about $fpath. As usual, I then typed env to check it participating in my environment but to my surprise it was not there! Yet, $FPATH (and $fpath) is ...
Brandt's user avatar
  • 324
5 votes
1 answer
422 views

Why does env -S with quoted strings in the shebang line work fine in Ubuntu but not in macOS?

I have the following script in an executable file test-shebang.mjs and I wanted to use zx to run my script but have my ~/.zshrc be sourced before that: #!/usr/bin/env -S zsh -c 'source ~/.zshrc; zx --...
runofthemillgeek's user avatar
2 votes
2 answers
48 views

How to source environment variable in command line with && combiner?

For a NodeJs app, I wrote the following script to deploy the app: "scripts": { "deploy": "source private/create_env.sh && ./deploy.sh", } private/create_env.sh ...
Alphonsio's user avatar
0 votes
0 answers
24 views

Terminal does not use .bashrc variables, but recognized them [duplicate]

I have installed the latest Pop!_OS version on my new computer and wanted to set the following environment variables: CC=/usr/bin/clang CXX=/usr/bin/clang++ CMAKE_GENERATOR=Ninja Instead of typing ...
mxHuber's user avatar
1 vote
0 answers
46 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
74 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
171 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
53 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
27 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.8k
-1 votes
2 answers
118 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
66 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
  • 3,087
0 votes
0 answers
43 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
731 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
267 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
120 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
191 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
59 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
149 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
200 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's user avatar
  • 103
4 votes
3 answers
1k 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,358
0 votes
0 answers
39 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
112 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
212 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
254 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
753 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
  • 859
1 vote
1 answer
174 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,164
0 votes
2 answers
80 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
1 vote
1 answer
398 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
190 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
581 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 ...
user avatar
0 votes
1 answer
614 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
136 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
124 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
151 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
73 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
67 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
389 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

1
2 3 4 5
31