Difference:
1, two files are set environment variable file,/etc/profile is a permanent environment variable, is a global variable,/etc/profile.d/set all users to take effect, is also a permanent variable, is a global variable.
2,/etc/profile.d/than/etc/profile good maintenance, do not want to what variables directly delete/etc/profile.d/under the corresponding shell script can, not like/etc/profile need to change this file.
3. It is important to note that/etc/profile and/ETC/PROFILE.D are also login-level variables that are triggered when the user logs back into the shell. So the effect is consistent.
4, usually set the login level of variables, re-login shell can, or source/etc/profile.
Originally:
Setting environment variables is usually written in/etc/profile, now it seems really low, if hundreds of applications, then find and modify to get is a different thing! So the problem is that the upgrade is done by creating a shell file in the/etc/profile.d/directory to apply the command, and then removing the required variables directly from the shell file.
Right now:
The same way, just create a new shell in the/etc/profile.d/directory, such as new Java:
vi/etc/profile.d/java.sh
Export Java_home=/data/service/java
Principle:
Whether in Linux or Mac, can be implemented in this way, analysis/etc/profile This file you will find a shell, this is the key:
if then for in/ETC/PROFILE.D/*. sh; do if [-R $i]; then . $i Fi-Done unset ifi
Summarize:
Do not use the same low way before, change the plan, so operation is the King!!!
The environment variable setting technique under Linux, do not need to/etc/profile but create a new shell file in the/ETC/PROFILE.D directory to set