Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
1 answer
2k views

Where to set env var for Debian12?

There are too many places can hold permanent env var settings in Linux, so that I can't finger out which one is the most correct/proper. /etc/environments /etc/bash.bashrc /etc/profile /etc/profile.d/...
Leon's user avatar
  • 239
-1 votes
1 answer
415 views

Set Variable to ls command output

I'd like to create a variable from the output of a bash command. How does one create a variable out of the output of the command "ls /Users". Variable creation does not work in this case: ...
Sam's user avatar
  • 11
1 vote
1 answer
65 views

Bash terminals launched from windows UI have an invalid `!::=::\` variable set

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
1 vote
1 answer
548 views

Expand variable to alias and execute

I have an alias set in my .bash_aliases file to execute neovim. I can successfully use this alias from the command line however I cannot use this alias via a variable (ie the EDITOR variable - set in ....
ljden's user avatar
  • 113
0 votes
1 answer
1k views

How to start tmux session that overrides environment variables set in .bash_profile?

Suppose I have an environment variable set inside .bash_profile: export ABC=from_bash_profile. $ echo $ABC from_bash_profile When I try to create a new tmux session with environment variables for ...
m01010011's user avatar
  • 151
0 votes
1 answer
877 views

Securing username and password passed as Environment variable

Username and Password are passed as plain text as environment variable while running a bash script from a existing process. using following command. sudo -u someuser USERNAME=abc PASSWORD=xyz /path/to/...
Saurabh Singh's user avatar
1 vote
0 answers
458 views

Environment Variable not showing up

I am implementing public private key based authentication and I need to parameters the location where I store my keys. So that, programmatically my jobs can read it from this location and establish ...
Srik's user avatar
  • 11
0 votes
2 answers
4k views

Setting environment variables in bash script doesn't work?

If I run this on the command line, it will make the commit be at the specified date: THE_TIME='2022-01-01T22:50:12 -0700' GIT_AUTHOR_DATE=$THE_TIME GIT_COMMITTER_DATE=$THE_TIME git commit -am 'commit' ...
Attribute's user avatar
0 votes
0 answers
1k views

How to copy file of env variable to another file

I am executing bash commands inside a yaml file. I have set an env variable SECRET which point to a yaml file in my home directory, and I want to copy the content of this yaml file to another file, as ...
Khalil Mebarkia's user avatar
0 votes
2 answers
1k views

Setting environment variables using eval - by calling other shell script

I have two shell scripts Caller and getGlobalParameters. There is a function defined in the getGlobalParameters script which calls a java class and uses the values returned by the java class to set ...
Sachin khot's user avatar
1 vote
1 answer
58 views

How to add environment variables to "mdkir -p" bash command?

Lets say I have an environment variable var="html,xhtml". I want to create a directory with subfolders, like so: mkdir -p Website/{static/{cs,js},templates/{html,xhtml}} How can I replace {...
Snow's user avatar
  • 229
0 votes
1 answer
6k views

Load ENV file from bash script

I have a bash script that has the following content : #!/bin/bash source ./django.dev.env docker compose --env-file ./uvicorn.dev.env -f ./docker-compose.yaml and a django.dev.env file with the ...
Nova's user avatar
  • 103
0 votes
2 answers
501 views

How to find where the variable come from in a bash set command?

It happens I have some unwanted environment variable inside the set command output, and I can't get rid of these: $ set ALL_PROXY=socks://127.0.0.1:10010/ .... (lots of environment variables) ...
imkzh's user avatar
  • 121
1 vote
3 answers
1k views

BASH Loop Through Variables

If i have a bunch of variables in bash, like this: foo_1="path/1" foo_2="path/2" foo_3="path/3" foo_4="path/4" foo_5="path/5" They all start with ...
T1M's user avatar
  • 85
6 votes
2 answers
6k views

Assign result of conditional expression to environment variable

I'd like to store the result of a conditional expression in an environment variable. I tried: C=$([ "$A" = "$B" ]) but the value of $C after running that is an empty string. I ...
user16768564's user avatar
2 votes
1 answer
867 views

Bash or zsh conditional patterns and variable expansions

Suppose I want to generate a filename based on some given variables. track=01 title="Some title" album="Some album" echo ${track}. ${title} (${album}) -> 01. Some title (Some ...
nadapez's user avatar
  • 232
0 votes
0 answers
78 views

Variables inside commands inside if statement

I do not understand why this does not work: existing_user=$(ldapsearch -x -b "cn=group,ou=group2,dc=company,dc=com" -H ldap://127.0.0.1 -D "cn=admin,dc=company,dc=com" -w "...
Belphegor's user avatar
0 votes
1 answer
1k views

$PATH editting does not work

I am using Ubuntu 64-bit on a VM and installed an app, added it to $PATH using export PATH=$PWD/bin:$PATH in my terminal (T1). Worked fine. Then i wanted to use the command in another terminal (T2) ...
longroad's user avatar
1 vote
2 answers
785 views

SHELL environment variable keeps returning the value of default shell

I'm using a terminal emulator with bash as the default shell ,then printed the value of the environment variable SHELL to print the current shell and it did , but when i enter another shell i.e., ...
xquilt's user avatar
  • 23
6 votes
1 answer
17k views

How to add a path to PATH variable in linux alpine for the entire machine?

I know I can export PATH="$PATH:my_path" to add to PATH variable in current session. I also know that I can add this line to ~/.bash_profile to make it persist across sessions for my user: ...
Saeed Neamati's user avatar
1 vote
1 answer
143 views

Modify .bashrc variable from a loop from shell

So I created this loop in ~/.bashrc: export test_var1=TRUE for (( a=0;a<1;a )); do if [[ $test_var1 == "TRUE" ]]; then sleep 1 echo "teststuff happening! test_var1=${...
Lha's user avatar
  • 13
0 votes
1 answer
997 views

Why giving an environment variable to sudo su fails?

Putting PATH variable into sudo su - USER occurs an error: USER1@SERVER:~:$ sudo PATH=$PATH su - USER2 sudo: sorry, you are not allowed to set the following environment variables: PATH Following the ...
yoon's user avatar
  • 141
3 votes
2 answers
6k views

sudo: sorry, you are not allowed to set the following environment variables

I set an alias for sudo as: alias sudo='sudo PATH=$MY_PATH' I checked that this works well by running sudo printenv PATH. However, I encounter an error when running sudo su - USER2. sudo: sorry, you ...
yoon's user avatar
  • 141
0 votes
1 answer
2k views

SHELL="/bin/bash" vs SHELL="bash"

What's the difference between exporting SHELL="/bin/bash" and SHELL="bash"? I previously had export SHELL="bash" in my .bashrc. It seemed to work. $($SHELL) spawned a ...
user2453676's user avatar
0 votes
1 answer
716 views

Sed special characters in variable '&'

Sorry, easy question, but I can't find how to do it: I have a special char "&" in a Variables that I have to use in sed. Example: #The template .env cat .env MY_SECRET = VAR_MY_SECRET ...
Sjoma's user avatar
  • 1
1 vote
1 answer
450 views

environment variable in scripts with heredoc

script: t1.sh DEST=`mktemp -d` echo "DEST=$DEST" script: t2.sh sudo -s <<EOF DEST=`mktemp -d` echo "DEST=$DEST" EOF invoking t1.sh, with or without sudo: $ bash t1.sh DEST=/...
xrfang's user avatar
  • 141
1 vote
1 answer
7k views

How do I set environment variable by importing from a file?

I know set command sets environment variables temporarily while set command sets environment variables permanently. This command exports current environment variable path to a file echo %path% > ...
JJJohn's user avatar
  • 465
0 votes
1 answer
378 views

`wsl env` gives different result to `wsl` followed by `env`

Inside WSL (i.e. by opening a cmd and then running wsl, or just running wsl straight from the start menu) I have this line at the end of ~/.bashrc: LANG=en_US.UTF-8 While still inside WSL, if I do ...
Clonkex's user avatar
  • 1,097
10 votes
2 answers
2k views

Can a process run regardless of any shell?

I'm trying to grasp the concepts of shell and terminal and the exact relation between them from the aspect of OS processes. So I have few questions in that field. Sanity check: As far as I understand,...
YoavKlein's user avatar
  • 315
0 votes
1 answer
586 views

my terminal is not recognizing my flask command after i installed flask

I ran into a problem with the terminal, it didn't recognize my flask command! the whole issue started with WARNING: The script isort is installed in '/Users/bigdad/Library/Python/3.8/bin' which is not ...
afbigdad's user avatar
2 votes
1 answer
1k views

concatening a variable to a file using cat

I wanted to do a bash function that given a text variable, it would concatenate it to a file. i.e function print() { cat << 'EOF' >> file This $1 is a variable EOF } But it wouldnt work. ...
Valku's user avatar
  • 23
0 votes
0 answers
45 views

Built in terminal extensions showing different files than default bash terminal

I'm attempting to use a Sublime Text 3 extension Terminus, on Clear Linux, but am having a strange issue I did not run into on Ubuntu 20 - the same issue applied to the other similarly functioning ...
user7778287's user avatar
0 votes
2 answers
962 views

Change home directory

I'm trying to access a folder with a bunch of files via cd $HOME_KADATH however I'm thrown into my 'normal' home directory. Is there anyway to change the home directory to the one above instead? This ...
Linus's user avatar
  • 1
1 vote
1 answer
511 views

Setting Environment variable for bash/zsh completion

I am using gnu pass with bash/zsh completion. This means when I type pass a[TAB] the shell suggests which passwords I have available starting with a. I have two gnu-pass directories, when I want to ...
simao's user avatar
  • 903
2 votes
1 answer
3k views

Is there a way to query WSL environmental variables from within Windows / Command prompt?

On my quest to make my WSL Windows Toolbar Launcher working, I found out that my attempt to set environmental variables for WSL from within command prompt futile: Within command prompt, I can do a wsl ...
menuhin's user avatar
  • 131
0 votes
0 answers
23 views

Setting many variables written in a file to set in the environment of Shell at a time?

I have written many variables to be set as environement variables in a file , how should i set them all at a time . Sample Code in File : BRUN_ABORT_DEPENDENT_JOBS_ON_NONZERO_EXIT="true"; export ...
rajivdesh's user avatar
0 votes
1 answer
783 views

Adding executable files to my PATH in a Linux shell

My goal is to run the R file helloworld.r from my home directory using Rscript in a Linux shell. My helloworld.r file looks like this #!/home/usr/env Rscript print("Hello World") I have added export ...
Ctat41's user avatar
  • 1
0 votes
1 answer
47 views

Can systemctl return an empty code?

Consider the following setting: systemctl is-active --quiet $SERVICE_NAME STATUS=$? Can it happen under any circumstances that $STATUS is then not set or empty? That is, because systemctl returns no ...
J. Doe's user avatar
  • 471
1 vote
0 answers
132 views

How do I ensure bash *never* expands paths in environment variables when tab-completing?

$ bash --version GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu) I normally using the above bash version on an Ubuntu 16.04 machine via MATE terminal. Currently however I am using macOS 10....
mystery's user avatar
  • 293
0 votes
1 answer
1k views

How to pass whole environment from target Linux to client Linux over one ssh session?

I have script on target Linux (RedHat, PC_A) which I would like to execute from source Linux (RedHat, PC_B) during remote login session. I'm trying to execute following command : [user2@PC_B] ssh &...
willy083's user avatar
0 votes
1 answer
6k views

Why I can't permanently remove these environment variables into an Ubuntu 18.04 system?

I am not so into Linux and I have the following problem related to how permanentlyunset some environment variables. The problem is that each time that I log into my system, performing the env command ...
AndreaNobili's user avatar
  • 7,201
0 votes
0 answers
32 views

Why performing the env command I obtain different values of the environment variables declared into "/etc/environment"?

I am working on an Ubuntu 18.04.2 LTS system and I have the following doubt. Into the /etc/environment file I have delcared the following variables: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/...
AndreaNobili's user avatar
  • 7,201
1 vote
0 answers
66 views

Trying to pass few variables to linux session from a flat file [duplicate]

I need to export around 10 variables to a session. To do this, I've put all these 10 variables in a flat file and trying to launch this flat file from shell using sh flatfile But these variables ...
drj's user avatar
  • 21
2 votes
1 answer
2k views

Why on printenv I cannot see the HOSTNAME enviromental variable? [duplicate]

On my ubuntu machine where I rin the following command: printenv | grep HOSTNAME Shows no output whilst when I do the following on terminal: echo ${HOSTNAME} Output is shown. SO I wanted to know ...
Dimitrios Desyllas's user avatar
0 votes
1 answer
2k views

Bash shell in mac terminal and iterm2 don't honor proxy environment variables

I have a 2019 mac running MacOS 10.14.6. I've had it configured to use my company's corporate proxy for about a month and various command line programs such as curl, brew, and git behave as expected ...
David Watson's user avatar
1 vote
1 answer
628 views

Supervisor and Shell command discrepancy: export variable from file working for in supervisor but not in shell, why?

suppose there's a file into /tmp/confs.sh, that looks like: export CONTAINER_CODE_PROJECT_ROOT="//var/www" and it's used inside a supervisor configuration file like this: [program:laravel-horizon] ...
Sim Sca's user avatar
  • 41
1 vote
1 answer
5k views

How do I create an environment variable "openssl"

I know my question may sound stupid but there's some problem I've been fighting with for the last 2 days. I have a few versions of OpenSSL installed on Ubuntu server. The one which is desired is ...
J doe's user avatar
  • 11
2 votes
2 answers
3k views

script with "export" command in a crontab

I have this in cron tab: * * * * * /root/attente.sh and attente.sh : export attente=$(cat /root/switchboard.txt) If I run export attente=$(cat /root/switchboard.txt) in a shell it works but not in ...
Bryan's user avatar
  • 23
0 votes
0 answers
268 views

incomplete PATH env var in IntelliJ IDEA terminal

I have a .bashrc that sets PATH, and also sources another file that extends said variable and defines new ones. Looks like in bash opened via IDEA terminal, the PATH extension from this sourced ...
basher's user avatar
  • 1
0 votes
0 answers
35 views

Bash puzzle of the week

We're having a very strange puzzle related to character encodings and bash replacement, where we are passing a bash variable into a rake script that gets piped into a different bash variable, and I'm ...
user3015971's user avatar

1
2 3 4 5