By using the startup script, you can make the custom environment ready for use once and for all.
These scripts run when the shell is created.
The startup scripts run vary depending on whether the shell is used to log on to the shell or not.
We use "Su-" to log on to shell; "Su" to log on to non-shell.
Typical examples in the startup script include:
① Local variable settings, especially PS1
For example, my:
[oracle@10gR2 ~ $]tail -f .bash_profile | grep -n --color=auto 'PS1'10:export PS1='[\u@10gR2 \W \$]'
② Environment variables such as path
③ Alias
④ Umask
(I) log on to Shell
/Etc/profile is the first startup script to run after the shell is started.
It only runs for the login shell; non-login shell will not trigger this script
Log on to the shell to load the startup script in the following sequence:
/Etc/profile →/etc/profile. D →. bash_profile →. bashrc →/etc/bashrc
Each called script will sequentially cancel the changes in the previous call script.
When logging out of shell, we can also execute some tasks, such as creating automatic backup and clearing temporary files.
Place these tasks in the. bash_logout file.
(Ii) Non-Logon Shell
The sequence of loading startup scripts for non-login shell:
. Bashrc →/etc/profile. d