Set global environment variables from a custom file

Works for a Living

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?

Eduardo Trápani

/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] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Global environment variables in Eclipse and Yosemite

분류에서Dev

Load environment variables from file just for the next script

분류에서Dev

Where is file that saves Environment Variables?

분류에서Dev

How to set environment variables in travis-ci and access them from python script?

분류에서Dev

How to set environment variables with sudo -u USER?

분류에서Dev

How to export Environment variables to a text file

분류에서Dev

Storing all environment variables in one file

분류에서Dev

how to set environment variables CAIROMM_CFLAGS and CAIROMM_LIBS

분류에서Dev

Django import variables from file

분류에서Dev

Windows batch file - splitting a string to set variables

분류에서Dev

Set variables in batch file with registry values

분류에서Dev

How to get all variables (and functions names) from the global scope in Jint?

분류에서Dev

Manipulation with user and system environment variables from command line in Windows 10

분류에서Dev

Is it possible to pass environment variables from child to parent in user space?

분류에서Dev

Reading a file path from text file with environment variable in C#

분류에서Dev

Limit of performance benefit gained in Python from using local variables instead of global variables?

분류에서Dev

Global Variables not working - Android

분류에서Dev

Weird issue passing variables from text file

분류에서Dev

Creating a global style from a file using styled-components' createGlobalStyle()

분류에서Dev

Closure Templates: setting global variable from passed paramater in soy file

분류에서Dev

Accessing Environment Variables in flash

분류에서Dev

Bash - check environment variables

분류에서Dev

How to set a background to an element from a JSON file

분류에서Dev

testing variables from a text list to set value in batch

분류에서Dev

testing variables from a text list to set value in batch

분류에서Dev

Can the environment variables for a modified environment be accessed externally?

분류에서Dev

Alternative to delcare global variables in Java

분류에서Dev

Python understanding structure and global variables

분류에서Dev

Where is this environment variable set?

Related 관련 기사

  1. 1

    Global environment variables in Eclipse and Yosemite

  2. 2

    Load environment variables from file just for the next script

  3. 3

    Where is file that saves Environment Variables?

  4. 4

    How to set environment variables in travis-ci and access them from python script?

  5. 5

    How to set environment variables with sudo -u USER?

  6. 6

    How to export Environment variables to a text file

  7. 7

    Storing all environment variables in one file

  8. 8

    how to set environment variables CAIROMM_CFLAGS and CAIROMM_LIBS

  9. 9

    Django import variables from file

  10. 10

    Windows batch file - splitting a string to set variables

  11. 11

    Set variables in batch file with registry values

  12. 12

    How to get all variables (and functions names) from the global scope in Jint?

  13. 13

    Manipulation with user and system environment variables from command line in Windows 10

  14. 14

    Is it possible to pass environment variables from child to parent in user space?

  15. 15

    Reading a file path from text file with environment variable in C#

  16. 16

    Limit of performance benefit gained in Python from using local variables instead of global variables?

  17. 17

    Global Variables not working - Android

  18. 18

    Weird issue passing variables from text file

  19. 19

    Creating a global style from a file using styled-components' createGlobalStyle()

  20. 20

    Closure Templates: setting global variable from passed paramater in soy file

  21. 21

    Accessing Environment Variables in flash

  22. 22

    Bash - check environment variables

  23. 23

    How to set a background to an element from a JSON file

  24. 24

    testing variables from a text list to set value in batch

  25. 25

    testing variables from a text list to set value in batch

  26. 26

    Can the environment variables for a modified environment be accessed externally?

  27. 27

    Alternative to delcare global variables in Java

  28. 28

    Python understanding structure and global variables

  29. 29

    Where is this environment variable set?

뜨겁다태그

보관