I am trying to execute a file containing environment variables so that whenever I log in, those variables are immediately accessible.
The $PATH
variable is defined in /etc/environment
so underneath that I put:
. /path/to/variables
I didn't think variables needed to be chmod 755
because it works if I run the above manually. But I tried chmod 755
on it and it still isn't loading on session start.
Inside /path/to/variables
I have several variables set. They all work fine, but only when I manually run . /path/to/variables
on each new session.
I have also tried placing . /path/to/variables
inside my ~/.profile
and restarting the session. Still doesn't work.
Yes, I could place my variable declarations inside /etc/environment
itself, but I want to keep them stored in my own file for organization purposes.
Am I missing something obvious or going about this entirely wrong?
/etc/environment
This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line.
That means that you cannnot include something like you meant to.
This information comes from Environment Variables. You will find there alternatives for what you were trying to do.
The right way to modify /etc/profile
is by adding a script to /etc/profile.d
with the a name in the form my_script.sh and a content like this:
export MYVAR="my value"
As this is now an actual shell script, you can also add something like:
. /path/to/variables
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다