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.

216 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
0 answers
2k views

Passing environment variables around in systemd

EnvironmentFile is not an option as per this answer. I am trying to understand the recommended way of using and passing environment variables. I have a urxvtd.socket: [Unit] Description=urxvt ...
themagicalyang's user avatar
6 votes
0 answers
1k views

Environment variable to override GTK icon theme

There is an environment variable available for overwriting current system GTK theme, GTK_THEME. Is there anything available for icon theme as well as for overwriting current icon theme?
NothingSpecial's user avatar
5 votes
0 answers
327 views

Tracing environment variable modification in the fish shell

There's one item I used to use in $PATH, which is ~/.workspace/bin. I can't figure out where it's coming from. I changed the user shell to /bin/sh, logged in from TTY, checked $PATH, and it was clear ...
skrat's user avatar
  • 255
5 votes
0 answers
2k views

How to protect an EnvironmentFile used by a systemd service?

Background I have multiple RESTful web services being deployed through Azure DevOps Release Pipelines to a CentOS VM. Each of these services is managed by systemd and uses environment variables to ...
tobias's user avatar
  • 151
5 votes
1 answer
911 views

Global Environment Variables for Users & systemd

I have a set of environment variables that I need to be globally set for all users and all systemd services. I don't want to have to specify them it two different locations. I tried setting them /...
Verax's user avatar
  • 243
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 ...
eang's user avatar
  • 565
5 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. ...
Hezi's user avatar
  • 61
4 votes
0 answers
620 views

How to configure environment variables per graphical session

Consider the following setup: I have GDM installed I have multiple graphical sessions configured, both X11 and Wayland: i3, sway, gnome(x11). I want to export different sets of environment variables ...
Danilа Maslennikov's user avatar
4 votes
0 answers
2k views

How to set `XDG_DATA_DIRS` for first `/usr/bin/gnome-shell` process?

I want to add a path to XDG_DATA_DIRS as seen by gnome-shell. Here's what I tried so far. I run htop, filter by gnome-shell and then pick the top most /usr/bin/gnome-shell with the smallest process ID ...
Vey's user avatar
  • 141
4 votes
0 answers
288 views

How to explicitly set the tabname of a new gnome-terminal?

I want to explicity rename a tab in gnome-terminal on startup of the tab. I don't want to use gnome-terminal --title flag as that gets reset by my systems bashrc file after whatever else is supposed ...
Prodnegel's user avatar
  • 141
4 votes
1 answer
152 views

Protecting process's envvars from exposure

From I've read about current best practices for developing web applications (such as the Twelve Factor guide), the recommended approach for storing configuration data is within environment variables. ...
Xion's user avatar
  • 141
4 votes
0 answers
2k views

Reading from /etc/environment with sudo

Using Ubuntu 14.04 LTS, I'm having a problem trying to read environment variables from /etc/environment when using sudo env. Basically, they are not being displayed. When I do just env, these ...
limc's user avatar
  • 153
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=...
Jan Černý's user avatar
  • 1,331
3 votes
0 answers
81 views

Scaling of icons does not work for gtkmm applications

I have a 4K display, and the correct scaling would be 3x. I have put Xft.dpi: 300 in .Xresources and GDK_SCALE=3 GDK_DPI_SCALE=-1 in /etc/environment. This can scale most applications, but the C++ ...
Rehpotsirhc's user avatar
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 ...
dramzy's user avatar
  • 131
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. ...
MrSnrub's user avatar
  • 175
3 votes
0 answers
538 views

Arch Linux with Mate ignores exports in ~/.bash_profile and ~/.profile

I use Arch Linux and need to add environment variables on login. I have Plasma, Cinnamon and Mate installed. For some reason the environment variables in ~/.profile and ~/.bash_profile are not set ...
Black-Pixel's user avatar
3 votes
0 answers
6k views

Custom GCC installation - how should I set my environment variables?

After some pains I was finally able to build me a gcc 4.9.3 (I don't have root on the machine I'm working on, and Fedora 22 doesn't package gcc 4.9 anyway). And it even works, i.e. using it to compile ...
einpoklum's user avatar
  • 9,462
3 votes
0 answers
255 views

Is it possible to make an exec call that "returns"?

Is there a way to make the exec system call work like a function call that returns instead of totally replacing the current process image? My motivation is trying to integrate two shells with ...
hugomg's user avatar
  • 5,707
3 votes
1 answer
621 views

Why does xdg-open text_file differ from sudo -u me xdg-open text_file?

If I run the following command, the text file opens in my preferred editor (kate). $ xdg-open text_file However, if I try the following, where sparhawk is my username, I get several warnings, and ...
Sparhawk's user avatar
  • 19.9k
3 votes
0 answers
871 views

assigning a multiline variable (tcsh prompt) to another

For tcsh, I have a prompt that is multiline: set prompt = "%/\\ %n@%m[%h]% " This shows the cwd on one line and then the user/host on second line. However, with this, I cannot make a copy of that: ...
pcm's user avatar
  • 171
3 votes
1 answer
2k views

Why does SSH_AUTH_SOCK and SSH_AGENT_PID unsets after a while in Amazon Linux?

We have a build system that needs an active ssh connection with mercurial and to do so, it needs an ssh-agent loaded with a key constantly.. The thing is that, even though that after creating the ssh ...
christopher de jesus's user avatar
2 votes
2 answers
771 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 ...
LearningC's user avatar
2 votes
2 answers
1k views

Open new terminal with environment specified by source command

I want to run a command that opens a terminal and sources into it a set of variables. How can I do this? I'm using xfce4-terminal. It has a command-line arg "--command", to execute commands ...
markling's user avatar
  • 213
2 votes
0 answers
97 views

Why `declare -p VAR` returns "declare -- VAR" on an unset local variable but gives an error "bash: declare: A: not found" on an unset global variable?

I don't understand: $ declare -i VAR=0; \ > echo "$A"; \ > fun() { local -i VAR=1; echo {; echo "$VAR"; declare -p VAR; unset VAR; echo "$VAR"; declare -p VAR; echo ...
The Quark's user avatar
  • 270
2 votes
0 answers
388 views

Where do I export gnome-keyring-daemon's ssh agent socket so that it is available at launch of WM?

I use gnome-keyring to manage my ssh keys. In order for that to work, I must set $SSH_AUTH_SOCK accordingly, which is prodived by gnome-keyring-daemon -s. For use in shells, I can easily do this in my ...
fab_mene's user avatar
2 votes
1 answer
873 views

Cannot change directory (cd) or use Working Directory Systemd Exec commands

I am trying to get a startup script (systemd service) for docker-compose containers. I am struggling to get it working, and have made changes and changes; with some things working, and other things ...
CvRChameleon's user avatar
2 votes
0 answers
1k views

In a user service, it possible to inherit environment variables from the user session?

Normally, services started with Systemd are given a "clean" environment that does not inherit from the user session. This is by design and it is a good default. However, I've written some ...
shadowtalker's user avatar
  • 1,318
2 votes
0 answers
213 views

source .pam_environment file

I'm using the .pam_environment file for some of my global environment settings, but whenever I make a change to the file, I need to log out and log back in again to see the changes since the syntax is ...
Subbeh's user avatar
  • 420
2 votes
0 answers
1k views

How to set environment variables system-wide

I'm trying to set an environment variable in such a way that all services as well as all shells have access to these environment variables. /etc/environment does not seem to do that. When I set them ...
Philippe's user avatar
  • 431
2 votes
0 answers
48 views

Plasma hot update environment variables

Is there a way to update the environment variables defined in the running plasma session in order to be able to only restart the affected applications instead of having to logout/login?
francescortiz's user avatar
2 votes
0 answers
462 views

Write stdout to a temp file using command line

Say for example we wanted to write the env from the host to Docker container, one way would be to use a temp file: env > env_file && docker run --env-file env_file image_name to avoid a ...
Alexander Mills's user avatar
2 votes
0 answers
382 views

Ruby script is not picking up sourced env vars

I am using environment variables in a Ruby script. When I export the variables and run the script as follows, it works fine. export ELK_URL="https://localhost:3241" ruby ./my_script.rb The contents ...
dknight's user avatar
  • 121
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/...
Otis Wright's user avatar
2 votes
0 answers
184 views

autocomplete with inline variable setting

I use bash version 4.4.19(1)-release (x86_64-apple-darwin17.3.0) on my Mac with MacOS (10.13.6) For example, I have autocomplete set up for the AWS CLI, via complete -C '/Users/jstoner/Library/...
John Stoner's user avatar
2 votes
0 answers
456 views

Issue setting environmental variable in tmux and screen

Whenever I use Tensorflow (a python library) from within a tmux or screen session, I have to manually change the environmental variables. Specifically, I have to type export PATH blah blah blah and ...
Ari Herman's user avatar
2 votes
0 answers
135 views

modprobe in setuid contextmodprobe in setuid context

In CVE-2017-0358, author notes that The issue is that /sbin/modprobe is not designed to run in a setuid context. As the manpage of modprobe explicitly points out The MODPROBE_OPTIONS environment ...
Jithin Pavithran's user avatar
2 votes
1 answer
662 views

Is there a plugin or tool for multiple "profiles" in ZSH?

I use oh-my-zsh for all of my console goodness. Depending on what I'm working on, there are certain environment variables that I'm often overwriting either manually or through scripts to make my work ...
A.J. Brown's user avatar
2 votes
1 answer
1k views

Can I use an environment variable to define an alias?

I'm using an automation engine to run perl scripts. script_X requires a wrapper script so it's run like: wrapper_script script_X --parameters But the automation engine can't understand that ...
ponytailPalm's user avatar
2 votes
0 answers
2k views

$PATH variable on Fish Shell OS X

I have somehow screwed up my path variables with Fish shell on OS X. Is this the proper $PATH variable in the config.fish? user@host ~> more ~/.config/fish/config.fish set -g -x PATH /usr/local/...
Ansel Gaddy's user avatar
2 votes
0 answers
118 views

Environment variables for packages built in custom location

Some time ago (month or so) I started to install packages that I build from source in custom location ~/.local so that I can easily distinguish which I build from source, and for other reasons, ...
zetah's user avatar
  • 2,037
2 votes
1 answer
295 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
0 answers
39 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
1 vote
0 answers
138 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
1 vote
0 answers
83 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
1 vote
0 answers
429 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,478
1 vote
1 answer
102 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[&...
Dims's user avatar
  • 3,255
1 vote
0 answers
705 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 ...
Phylliade's user avatar
  • 145
1 vote
1 answer
572 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 ...
Lockszmith's user avatar

1
2 3 4 5