Linux shell script execution and configuration files
Bash Script Execution method:
1 interpreter runs/usr/bin/bash bash foo.sh 2 run script with path (requires x permission) chmod +x foo.sh/path/to/foo.sh 3 use. or so The Urce command executes the script. /path/to/foo.sh source/path/to/foo.sh The difference between the execution method and the 3 execution method: 1, 2: The interpreter being executed is a subroutine and therefore does not affect the variables of the current shell. 3: The interpreter being executed is the current shell program, which reads the variables and overwrites the variables for the current environment. (typically used to set default variables)
Bash's configuration file
Global Configuration /etc/profile /etc/profile.d/*.sh /etc/bashrc Personal Configuration ~/.bashrc ~/.bash_profile ~/.bash_logout profile Series File: (1) for defining environment Variables (2) Run a command or script         BASHRC series file: (1) define command aliases and functions (2) Define local variables .bash_logout: scripts executed before the user exits the login
Bash Interactive login and non-interactive login
Interactive logon and non-interactive logon differences: Read profile different switch command: SU USERNAME non-interactive su-username interactive logon interactive logon read profile order:/et C/profile---/etc/profile.d/*.sh---~/.bash_profile----~/.BASHRC to read the configuration file in sequence: /ETC/BASHRC-~/.BASHRC-/etc/profile.d/*.sh Note: When the interactive shell switches to a non-interactive shell, it first inherits all the variables of the parent shell, then reads the variables in the corresponding configuration file and Overwrite an existing variable.
Variable check and change
set set lists the variable names and their values in the current shell env env list the current shell environment variables unset unset name Remove variable names $- show enabled features for set # echo $- himBH h : whether to open hash Whether i : is an interactive shell m : whether to open job control b : whether to open the extended functionality of {} C : Whether override redirection is turned on   &Nbsp; h : whether to enable the history expansion command and use! Wait for the shortcut call
This article is from the "12064120" blog, please be sure to keep this source http://12074120.blog.51cto.com/12064120/1963915
Shell script execution and configuration files