System-Level startup files
====================================
1,/ETC/RC master boot file, do not modify it
2,/etc/rc.conf decided to launch which system comes with the daemon, do not modify it
3,/etc/rc.conf.local If you want to interfere with the daemon that starts when the system starts, please edit this file and the contents of this file will overwrite the contents of/etc/rc.conf.
4,/etc/rc.local focus, you want to let nginx,mysql,tomcat self-initiated, please modify this file.
5,/etc/rc.shutdown Focus, in the operating system shutdown, can be closed nginx,mysql,tomcat
1, /etc/rc.local
The system starts the Daemon (service) and executes the program that needs to be loaded. The file has only one "exit 0" statement, the user can join their own startup program, but need to ensure that the final return is 0.
Note that the script under the user shell cannot be added to this file, for example, adding alias ll= "Ls-l" is invalid because the execution environment of the file is under the system shell and the system has not yet entered the user shell environment.
Configurable environment variable, can do boot from boot, because the boot program needs to use environment variables.
Bash (user-level) startup files -[Ubuntu] (/etc/profile,/ETC/BASHRC, ~/.profile, ~/BASHRC files)
====================================
1) Enter the system, first execute the/etc/rc.local file, then/etc/profile the file, and then execute the/ETC/BASHRC file; After the end, go to bash (if the user is logged in), first execute the/etc/profile file, and then execute the/home /user/.bash_profile file, according to the file, executes the/HOME/USER/.BASHRC file, and then according to the file, executes the/ETC/BASHRC file, after execution, the entire execution process is completed.
2) switch user (such as from the root user to switch to WXC user), using the "su" command, the system first executes the/HOME/WXC/.BASHRC file, and then according to the file, execute the/ETC/BASHRC file, after execution, the entire execution process is completed, when using the "Su-" command, Execute the/etc/profile file first, then execute the/etc/profile.d/*.sh and/home/wxc/.bash_profile files, execute the/HOME/WXC/.BASHRC file according to the file, and then execute/etc/according to the file. BASHRC file, after execution, the entire execution process is completed.
(1)/etc/profile
A global (public) configuration that reads the file when logged on, regardless of the user.
Configurable environment variables, such as Java_home
MAC has this file
(2)/ETC/BASHRC
Global (public) configuration, which will be read by the bash shell, regardless of the way it is executed.
MAC has this file
Ubuntu does not have this file, and it corresponds to the/ECT/BASH.BASHRC
(3) ~/.BASHRC
This file is read when the bash Shell is executed in the form of Non-login. If executed in login form, this file will not be read.
The file is read when it is logged on and every time a new shell is opened.
The ~/.bash_profile is roughly the same as the ~/.BASHRC setting, so the former usually calls the latter.
(4)~/.bash_profile
This file will not be read until the bash shell is executed in login mode. The file is only executed once! By default, he sets some environment variables to execute the user's ~/.BASHRC file.
The ~/.bash_profile is roughly the same as the ~/.BASHRC setting, so the former usually calls the latter.
Mac has this file (note: Linux is. BASHRC and Mac is. Bash_profile)
Unbutu does not have this file by default and can be created.
(5) ~/.bash_login
If bash shell is executed in login mode, read ~/.bash_profile, if it does not exist, read ~/.bash_login, if the first two do not exist, read ~/.profile.
(6) ~/.profile
If bash shell is executed in login mode, read ~/.bash_profile, if it does not exist, read ~/.bash_login, if the first two do not exist, read ~/.profile.
In addition, when graphical mode is logged in, this file will be read even if there are ~/.bash_profile and ~/.bash_login.
MAC does not have this file by default, you can create this file manually
(7) ~/.bash_logout
This file is read when it is logged off and is in longin form. That is, when the text mode is logged off, the file is read, and when the graphics mode is logged off, the file is not read.
Setting environment variables
Export Xxx=xxxx
For example Export http_proxy=http://example.com:8080
Delete environment variables
unset xxxx
For example unset http_proxy
Here are a few examples of native (Ubuntu)
====================================
1. Graphical mode login, sequential read:/etc/profile and ~/.profile
2. Graphical mode login, when opening the terminal, sequential read:/ETC/BASH.BASHRC and ~/.BASHRC
3. Text mode login, sequential read:/etc/bash.bashrc,/etc/profile and ~/.bash_profile
4. From the other user su to the user, there are two cases:
(1) If the WITH-l parameter (or-parameter,--login parameter), such as: Su-l username, bash is lonin, it reads the following configuration file sequentially:/etc/bash.bashrc,/etc/profile and ~/.bash_ Profile
(2) If there is no-l parameter, bash is non-login, which reads sequentially:/ETC/BASH.BASHRC and ~/.BASHRC
5. When logging off, or exiting the SU login user, if it is longin, then bash reads: ~/.bash_logout
6. When executing a custom shell file, if you use "Bash-l a.sh", bash reads the lines:/etc/profile and ~/.bash_profile, if other ways, such as Bash a.sh, are used./a.sh,sh A.sh (this does not belong to the bash shell), it will not read any of the above files.
7. The above example is usually read to ~/.bash_profile, if the file does not exist, then read the ~/.bash_login, if the first two do not exist, read ~/.profile.
Linux startup files, setting the location of environment variables