将 bash 脚本添加到 /etc/profile.d/ 以加载变量?

将 bash 脚本添加到 /etc/profile.d/ 以加载变量?

bash作为对环境环境变量,我看到:

/etc/profile.d/*.sh

Files with the .sh extension in the /etc/profile.d directory get executed whenever a bash login shell is entered (e.g. when logging in from the console or over ssh), as well as by the DisplayManager when the desktop session loads.

You can for instance create the file /etc/profile.d/myenvvars.sh and set variables like this:

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0
export PATH=$PATH:$JAVA_HOME/bin

这样的脚本作为:

#!/bin/sh
export AccessToken=678
export AccessTokenSecret=wxy
export ApiKey=abc
export ApiSecret=123

可以安全地添加到,/etc/profile.d/以便 powershell脚本会带来变数吗?

相关内容