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
17 votes
1 answer
6k views

Turn on xtrace with environment variable

Bash has a sometimes-useful feature whereby if you turn on the "-x" option (I believe the symbolic name is xtrace), Bash outputs each line of script as it executes it. I know of two ways to enable ...
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 ...
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, ...
3 votes
1 answer
2k views

Allow user to run command as another user with their environment in sudoers

So, I have an entry that looks like this in my sudoers file: user1 ALL=(user2) NOPASSWD: /scripts/dir/ This allows user1 to run all executables under /scripts/dir/ as user2 without entering their ...
0 votes
2 answers
2k views

I cannot set env variable on zsh

I am using Kali linux: lsb_release -a " Distributor ID: Kali Description: Kali GNU/Linux Rolling Release: 2021.2 Codename: kali-rolling " i set env variable export DB_USER=...
1 vote
1 answer
2k views

Setting environment variable using shell script

I am using csh scripts for some automation purpose. I have a number of scripts, and the beginning of all of which I need to set a fixed set of environment variables. |----SCRIPT 1---| |----SCRIPT ...
62 votes
9 answers
71k views

What's the 'right' format for the HTTP_PROXY environment variable? Caps or no caps?

I've encountered both http_proxy and HTTP_PROXY. Are both forms equivalent? Does one of them take precedence over the other?
5 votes
2 answers
374 views

Why first set a variable and then export it instead of setting and exporting in one command?

If gpg-agent is executed, it outputs data that can be processed by a shell directly, e.g.: SSH_AUTH_SOCK=/tmp/ssh-apeOFqMF3292/agent.3292; export SSH_AUTH_SOCK; SSH_AGENT_PID=3293; export ...
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 ...
0 votes
2 answers
2k views

Unable to build using Java OpenJDK 14. /bin/sh: javac: command not found

I've been tasked to work on updating a Java program that hasn't been touched for years and I'm running into issues building it using the latest version of Java OpenJDK 14.0.1.7-2 on Centos 7. When I ...
2 votes
2 answers
719 views

Meaning of \ before environment variable

In ksh on an old Solaris box I used: export PS1="$PWD $" to set the prompt to the current directory. It works great until you cd elsewhere, then you see that it's not evaluating PWD each time. I ...
-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 ...
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 ...
3 votes
1 answer
4k 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=...
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 &...
367 votes
5 answers
589k views

How do I set an environment variable on the command line and have it appear in commands?

If I run export TEST=foo echo $TEST It outputs foo. If I run TEST=foo echo $TEST It does not. How can I get this functionality without using export or a script?
-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 ...
146 votes
11 answers
390k views

Script to change current directory (cd, pwd)

I want to run a script to simply change the current working directory: #!/bin/bash cd web/www/project But, after I run it, the current pwd remains unchanged! How can I do that?
7 votes
5 answers
63k views

bash: shutdown: command not found

I installed the latest version of Debian (netinstall). I have the problem, that the terminal does not know commands like shutdown, reboot, and so on. When I do whereis shutdown it tells me it is in /...
112 votes
5 answers
78k views

If processes inherit the parent's environment, why do we need export?

I read here that the purpose of export in a shell is to make the variable available to sub-processes started from the shell. However, I have also read here and here that "Processes inherit their ...
3 votes
1 answer
2k views

Why doesn't sudo -E keep my $HOME environment variable?

On my Red Hat machine, when I run the command echo $HOME with my normal user account, I get /home/snrub. When I run the command sudo vim foo.txt and inside vim I type echo $HOME I get /root returned. ...
0 votes
1 answer
714 views

How to read symbol value directly from memory?

So what I need to do is read a kernel symbol directly from physical memory. I wrote a kernel module that exports a variable (symbol) using the following lines int test_var = 5; EXPORT_SYMBOL(test_var);...
5 votes
1 answer
3k views

Debian ignores PAM env variables (while Arch doesn't)

I have a weird issue with my Debian Sid system. I want to set a global environment variable in /etc/environment, which is supposed to be read by the pam_env module. Unfortunately, after having relogin ...
3 votes
2 answers
3k views

Current environmental variables of a process

This question relates to this answer. Is it possible to get the current (not initial) environmental variables of a process by making a child process and checking its initial environmental variables? ...
1 vote
1 answer
5k views

Uninstall Android Studio + SDK

I am using linux arch. I installed android according to ArchWiki. I uninstalled every skd component and android studio using pacman -Rs. Also, I removed every hidden folder in the home directory that ...
0 votes
1 answer
2k views

"export VAR=thing && someCommand" reports "export: `&&': not a valid identifier"

I'm trying to set an environment variable and execute a command in a single line, like this: export PUB_CACHE=/app/src/.pub-cache && dart-sdk/bin/dart server.dart (Don't ask why... it's ...
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 ...
65 votes
7 answers
98k views

How to read environment variables of a process

Linux's /proc/<pid>/environ does not update a process's environment. As I understand it, the file contains the initial environment of the process. How can I read a process's current environment?
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 ...
2 votes
1 answer
2k views

Exporting $PULSE_SERVER at start up

In order to run flatpak applications (like Discord or Spotify) I currently have to export the $PUSLE_SERVER in my ~/.zshrc or ~/.bashrc like so: export PULSE_SERVER=unix:/tmp/pulse-PKdhtXMmr18n/...
3 votes
3 answers
2k views

Is it safe to copy user's .bashrc to /root/.bashrc?

I am running Debian. The default /root/.bashrc is kinda empty. So if I do sudo -i to login as root, there are many things are not setup properly. Normally, I just do the following: $ sudo -i # mv ....
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 ...
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....
15 votes
2 answers
10k views

In `while IFS= read..`, why does IFS have no effect?

I might have something absolutely wrong, but it looks convincing to me, that setting IFS as one of the commands in the pre-do/done list has absolutely no effect. The outer IFS (outside the while ...
0 votes
1 answer
3k views

How to inherit XDG_SESSION_TYPE in systemd units?

My current desktop environment: Plasma Wayland. Many GUI applications can't be launched from within Emacs daemon (started by e systemd unit) unless XDG_SESSION_TYPE is set to "wayland". It's ...
489 votes
6 answers
446k views

What does "LC_ALL=C" do?

What does the C value for LC_ALL do in Unix-like systems? I know that it forces the same locale for all aspects but what does C do?
100 votes
4 answers
166k views

Replacing only specific variables with envsubst

I'm trying to perform environment variable replacement through envsubst, but I want to only replace specific variables. From the docs I should be able to tell envsubst to only replace certain ...
4 votes
2 answers
3k views

How to set global environment variables to all services?

I have seen that it should be possible, by using DefaultEnvironment= in /etc/systemd/system.conf. However, I'm not sure whether I can use expression expansions like PATH=$PATH:/whatever/path or not. ...
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? ...
1 vote
2 answers
587 views

env command shows 3 times same path

When I run env it shows 3 times /usr/bin under PATH. Same for every path under PATH title. For example - my scala bin directory shows 3 times. However, in my .bash_profile, it is written just one ...
9 votes
2 answers
513 views

How do you set up the environment for es?

I've been playing with es the last couple of days, and it (like rc) has the quirk/feature that it only runs its startup script (.esrc) on login. The usual way to run code in each interactive session ...
-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....
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 ...
-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"? ...
183 votes
6 answers
594k views

How do I set a user environment variable? (permanently, not session)

This is irritating me. I seen several suggestions (all using different files and syntax) and none of them worked. How do I set an environment variable for a specific user? I am on debian squeeze. ...
0 votes
2 answers
551 views

Cannot Display Bash Functions within FZF Preview Window

How do I get the FZF Preview Window to Display Functions from my Current Bash Environment? I want to list my custom bash functions using FZF, and view the code of a selected function in the FZF ...
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....
31 votes
2 answers
91k views

How to set environmental variable in systemd service

I'm working with ROS, which has been installed on my Ubuntu correctly. To run the ROS, we have to first source /opt/ros/kinetic/setup.bash then execute roscore. If I execute roscore without source ...
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 &...
3 votes
3 answers
15k views

Can't set up environment path variables in Kali Linux installation

I downloaded flutter and Android studio on my linux machine. It is a kali linux installation. I want to add environment path variable for both android studio and flutter permanently so, who when I ...

1
2 3 4 5
31