1. About the configuration file/etc/profile
This file is automatically executed when the system starts. Any user logs on to the system to execute this file.
The configuration in this file is global configuration. Therefore, if you want to allow all users to use your variables, you can add them in this configuration file.
For example, the configuration of JAVA_HOME variable.
However, do not modify the configuration file as far as possible because it is the system configuration file. We try to modify our independent configuration file.
You can modify your configuration file at any time when possible or when you reconfigure it, without affecting others or the server system.
Similarly, modifying/etc/rd. local can achieve the same effect.
But like the above, it is not a good choice.
What is the alternative?
First, let's look at the source code of/etc/profile.
If [-d/etc/profile. d]; then
For I in/etc/profile. d/*. sh; do
If [-r $ I]; then
. $ I
Fi
Done
Unset I
Fi
If ["$ PS1"]; then
If ["$ BASH"]; then
PS1 = '"u @" h: "w" $'
If [-f/etc/bash. bashrc]; then
./Etc/bash. bashrc
Fi
Else
If ["'id-U'"-eq 0]; then
PS1 = '#'
Else
PS1 = '$'
Fi
Fi
Fi
Explanation: 1. [-r $ I] indicates readable, and unset I indicates deleting the environment variable I.
The code in red indicates that/etc/profile will first execute all *. sh files in the/etc/profile. d/directory.
This gives us a scalable idea.
To configure JDK, create the jdk. sh file under/etc/profile. d /.
Example:
Jdk. sh
JAVA_HOME =/usr/lib/jvm/jdk1.6.0 _ 35
JRE_HOME = $ JAVA_HOME/jre
CLASSPATH =.: $ CLASSPATH: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib: $ JAVA_HOME/lib/tools. jar:/$ JAVA_HOME/lib/dt. jar
PATH = $ PATH: $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin:
Export JAVA_HOME JRE_HOME PATH CLASSPATH
Export PATH = $ PATH :~ /Bin
To configure oracle, create the oracle. sh file under // etc/profile. d /.
Then, add your own configuration in the corresponding configuration file.
This is the idea I used in the last two blogs.
========================================================== ==========================================