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
3 votes
1 answer
56 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 ...
  • 171
0 votes
1 answer
35 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 ...
  • 468
0 votes
2 answers
43 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 ...
  • 5
-3 votes
2 answers
57 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: ...
-2 votes
1 answer
37 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 ...
  • 313
0 votes
0 answers
27 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 ...
0 votes
2 answers
41 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 --...
  • 103
0 votes
0 answers
21 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 ...
  • 977
-1 votes
4 answers
47 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 ...
0 votes
1 answer
29 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 /...
  • 14.2k
0 votes
0 answers
19 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 ...
  • 101
-2 votes
2 answers
64 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 ...
  • 131
1 vote
0 answers
135 views

How to globally set all electron apps to have --enable-features=UseOzonePlatform --ozone-platform=wayland options?

I switched to wayland on arch linux and it introduced a lot of bugs. Many are related to electron apps. I have find out that I can solve them by starting apps with this options: --enable-features=...
  • 1,083
0 votes
0 answers
26 views

Installed Mysql using Tar ball, I want to execute mysql command from any dir [duplicate]

I have installed mysql version:8.0.32 using tar file. I am able to run mysql command only from bin dir inside the mysql dir. Logs: [memsql@rnd-4 mysql-8.0.32-linux-glibc2.17-x86_64-minimal]$ ls bin ...
  • 127
1 vote
1 answer
61 views

Temporary failure in name resolution in Python script running during boot or on shutdown

I wrote a Python script which sends any message via Telegram: #!/opt/anaconda3/bin/python import asyncio import telegram import os import sys async def main(): bot = telegram.Bot(os.environ[&...
  • 2,877
0 votes
0 answers
52 views

which wget returns error: /usr/bin/env: «node»: No such file or directory

I uninstalled nodejs the other day and now for some reason when I access it I get the error that node is not found. The argument of the which command can be anything. > which wget ...
0 votes
1 answer
20 views

systemd service: As which user is the EnvironmentFile directive read?

I have a systemd service with a config like: [Unit] Description=example systemd service unit file. [Service] ExecStart=/path/to/program EnvironmentFile=/etc/program.conf User=someuser [Install] ...
  • 131
0 votes
2 answers
217 views

Set and Test Enviornment Variables in .yaml files in Linux

I have one abc.yml file as below which contains username and password parameters. I have stored these parameters in env variable of my linux user But when application is execting abc.yml file it's not ...
  • 127
0 votes
0 answers
20 views

Source env variable resolved instead of local env variable

I am having the following issue with Enviroment variables: In my linux server I have an enviroment variable HOSTNAME (has value SERVER_HOSTNAME) In my Linux box I have another enviroment variable ...
0 votes
0 answers
17 views

Spawning a second terminal with inherited environment

From a shell running in one terminal window, I'd like to be able to run a command that spawns a second shell in a new terminal window, inheriting the environment of the first shell. With an executable ...
  • 1,736
2 votes
1 answer
42 views

Load variables with source with a single line scope

In bash and other shells, I can make same variables have "line scope" by defining it just before a command. CXX=clang++ ./script.bash Which I prefer over export CXX=clang++ ./script.bash ...
  • 113
0 votes
0 answers
10 views

How can I use email subject in the body automatically with [neo]mutt?

Say I'm composing an email with the subject Test Subject. Ultimately, I want an HTML body with <title>Test Subject</title> in it. Now, this could either be done by creating the text/...
0 votes
0 answers
460 views

"No X11 DISPLAY variable was set [...]" when using java.swing

When I'm trying to run a Java GUI application from the command line, I get: Exception in thread "main" java.awt.HeadlessException: "No X11 DISPLAY variable was set, or no headful ...
1 vote
1 answer
61 views

Environment variables not passed to the user

Even though I set ENVIRONMENT=production in /etc/environment and DefaultEnvironment=ENVIRONMENT=production in /etc/systemd/system.conf the variable ENVIRONMENT (which should be global by now) is not ...
  • 2,403
0 votes
0 answers
33 views

What "older versions of sh" that source in $ENV even for non-interactive shells are there?

In FreeBSD 13.1's man sh, in the "Invocation" section, it mentions: Unlike older versions of sh the ENV script is only sourced on invocation of interactive shells. This closes a well-known,...
1 vote
0 answers
30 views

What is the name of this ENV definition ${HOME:-/home}? [duplicate]

I am creating a shell script to deploy a container, and found in some docker files this definition of ENV: ${HOME:-/home}. I want to know what is the name of this kind of definition and where can I ...
0 votes
1 answer
38 views

How to correctly add variable to environment or session

I work with a opensource software that I have built locally. After build the manual says to run it like this while inside the build directory $ LD_LIBRARY_PATH=../applicationExeFile Then the ...
  • 764
0 votes
0 answers
28 views

Why xmonad does not see any application included in users $PATH variable?

I have recently installed MX Linux on my laptop XFCE ahs version. Along that I have installed xmonad. The problem is xmonad does not see any scripts or application that are included in my $PATH ...
2 votes
1 answer
265 views

sudo causes envsubst to print empty output

I have a script that exports some variables and in some places uses sudo. This is a simple example: export Name=John sudo envsubst < SourceFile > TargetFile And if the SourceFile has a $Name ...
  • 121
0 votes
0 answers
37 views

How to use Apache2 serverName directive as a variable or echo an environment var for virtualhost serverName

Hello linux community , I'm stucked, so i need your help. I made a symfony application under Raspbian buster which works with apache2, i need to make many disk images of this app to install it on many ...
0 votes
0 answers
36 views

What shell/env variable contains commandline suggestions?

Many years ago someone once showed me that if your shell returned a command suggestion then you could access it from a shell or environment variable. I thought this was very cool at the time but I ...
  • 113
0 votes
1 answer
71 views

Save every output of same command in different variables

#!/bin/bash SERVERLABEL=( 11011-22022 33033-44044-10101 55055-10001-20002 ) for vmlabel in "${SERVERLABEL[@]}" do linode-cli linodes list | grep $vmlabel | grep -E -o &...
  • 358
2 votes
1 answer
79 views

How to edit $PS1 variable so that the output of a bash command is another color than the command?

How to edit $PS1 variable so that the output of a bash command is another color than the command? For example, I want the command to be black, and the output to be green. username$ seq 1 3 1 2 3 In ...
  • 21
1 vote
1 answer
49 views

variable via SSH session

mount.cifs can use the variable PASSWD for password authentication. Well, the following example show the problem: export PASSWD=mysecret; ssh foreignhost "echo $PASSWD" works, it means, the ...
  • 143
0 votes
0 answers
19 views

Is it possible to export env vars to current shell, from within a child process/script [duplicate]

Is it possible to export env vars to the current shell, from within a child process/script that was executed from the current shell? Take this ultra-simplified example script: #!/bin/bash export FOO=&...
  • 121
0 votes
0 answers
23 views

How to put a brace expansion into a shell variable? [duplicate]

Given (as an argument to my script) is a string of unique characters (e.g. "ABCDE") of which I need to get all permutations (or at least iterate over those permutations). # SEG is one ...
2 votes
1 answer
71 views

TERM=fbterm causes box-drawing characters (by curses) get scrambled

I'm writing TUI software on fbterm using python-curses library. To get full color in fbterm, I read it's man page and concluded I need to change environmental variable TERM to fbterm. Man page: By ...
  • 460
3 votes
3 answers
568 views

How to load variables from a text file (.env) for a single process without exporting the variables?

Note: This general topic seems to be covered ad nauseum on more than one SE site, but please read through all the details — I don't find any questions which cover all the criteria described below. ...
  • 576
0 votes
1 answer
524 views

How can I find the value of $XDG_CONFIG_HOME, $XDG_CONFIG_HOME, $XDG_STATE_HOME, etc in a Bash script?

This seems like a simple question that every application developer would have, but I can't find the answer. Per the latest XDG Basedir Spec, there are many directories that should be defined in ...
0 votes
0 answers
52 views

Modify or remove specific environment variables on every logout

Whenever a (graphical) logout occurs on Debian 11, I want to conditionally (e.g. if $XDG_DEBUG == 1, then ...) set or clear specific environment variables for the active user. The environment ...
  • 252
0 votes
1 answer
41 views

How to send new information to STOPped process

Say I have a long-running process, and I stop and restart it using: kill -STOP <pid> kill -CONT <pid> is there a consistent way to alter the running process, either environment variables ...
0 votes
0 answers
23 views

Bash: env in rustup node module not found after logging in

I've used Rustup and Cargo for a Node project, and now I don't need them anymore, so tried removing both. However, each time I connect to the Raspberry Pi in question via SSH, I get this output: ~ $ ...
  • 101
0 votes
0 answers
186 views

How do variables exported in `/etc/profile.d` end up in the systemd user environment on Gnome?

On Gnome with Systemd, systemd user environment variables are configured using the systemd environment.d mechanism, which doesn't rely on shell scripts, but on configuration files. In parallel, many ...
  • 125
0 votes
1 answer
39 views

Set specific envionment variables on every login

It sounds like an easy task, but I could not achieve it so far: Whenever a (graphical) login occurs on Debian 11, I want to conditionally (e.g. if $XDG_DEBUG == 1, then ...) set specific environment ...
  • 252
0 votes
0 answers
37 views

On Linux/Debian should .bashrc have anything set for python/python3 and if so what?

What should be in the .bashrc for python/python3 on Debian11/KDE? To verify the environment variable is correct, what should echo $PATH display? which python3 displays /usr/bin/python3.
  • 3,694
0 votes
0 answers
40 views

What could cause the environment variables to not get loaded from ~/.bashrc at boot?

On one of my Debian11/KDE machines which uses X11, the environment variables don't get loaded from ~/.bashrc at boot and echo $PATH only prints very few (but not none!) variables. After booting I have ...
  • 3,694
1 vote
2 answers
220 views

How to take a screenshot over SSH?

I have an Ubuntu Desktop machine. My scope is to take a screenshot of this machine via SSH. This machine is playing a video, and I would like to take a screenshot of this video via SSH. I've tried as ...
0 votes
1 answer
132 views

Finding the address of an environment variable with and without GDB

I am trying to do an exploit, which spawns a shell, the shellcode is inside an environment variable and I launch the program or GDB with a clean environment so the variable is at the top. env -i MYVAR=...
  • 3
0 votes
1 answer
43 views

How does bashrc function differently from bash_profile?

I have been losing my mind due to IntelliJ not wanting to commit my code. I had put export GPG_TTY=$(tty) into my .bash_profile instead of my .bashrc; echoing $GPG_TTY responded with the proper path, ...
  • 1,675
1 vote
1 answer
185 views

Teeing each output while capturing return exit code (are any env variable) and passing it back "up the chain"

I've been struggling and reading quite a bit about this, and clearly bash is probably not the best tool for this, but since I'm already dug this deep into this hole (too much of the code is already ...

1
2 3 4 5
30