如果我输入终端,
export DISPLAY=:0.0
...存储该环境变量的外壳在哪里?
我正在使用 Ubuntu 8.10。我查看了文件 ~/.profile 和 /etc/profile 并且找不到 DISPLAY 的踪迹。
如果我输入终端,
export DISPLAY=:0.0
...存储该环境变量的外壳在哪里?
我正在使用 Ubuntu 8.10。我查看了文件 ~/.profile 和 /etc/profile 并且找不到 DISPLAY 的踪迹。
进程的环境变量存在于运行时,而不是存储在某个文件左右。它们存储在进程自己的内存中(在那里它们被发现传递给子进程)。但是里面有一个虚拟文件
/proc/ pid /环境
这个文件显示了调用进程时传递的所有环境变量(除非进程覆盖了它的那部分内存——大多数程序不会)。内核通过该虚拟文件使它们可见。可以一一列举。例如查看进程 3940 的变量,可以这样做
cat /proc/3940/environ | tr '\0' '\n'
每个变量由下一个变量的二进制零分隔。tr 将零替换为换行符。
键入“set”,您将获得所有当前变量的列表。如果你想让一些东西持久化,把它放在 ~/.bashrc 或 ~/.bash_profile 中(如果你使用的是 bash)
If you want to put the environment for system-wide use you can do so with /etc/environment
file.
它存储在进程(shell)中,并且由于您已将其导出,因此会产生任何进程。
执行上述操作不会将其存储在文件系统中的任何位置,例如 /etc/profile。你必须明确地把它放在那里才能发生。
There is 1 file that can be used to store env variables.
.bashrc
You can add your variables and use them. For example I have added Django virtual env as environment variable and now I can access it anywhere. Add this to your bashrc file
django_env='source/media/anish/Softwares/virtual_env/django2/bin/activate'
now you need to restart your system to reflect changes and after restarting enter $django_env to start your virtual environment. as simple as that.
As to the location of environment variables in RAM, they are stored in the top of the stack of main() function. any dynamic modification by setenv() et al. are then allocated elsewhere
该变量未存储在某些脚本中。它只是由 X 服务器脚本设置的。您可以使用set检查当前设置的环境变量。