shell command interpreter is used to explain the use of the user operating system cat / etc / shells can see the installation of the system shell
Linux boot process : the BIOS -> the MBR -> BootLoader (GRUB) -> Kernel -> systemd -> System Initialization -> shell
BIOS basic input-output system selection U disk or hard disk; the MBR hard disk bootable portion; BootLoader (grub) starts the launch kernel kernel selection tool;
kernel boot the kernel; systemd No. 1 the rest of the process all the processes derived from it; and only then start the system initialization shell
Execute scripts four ways
1 bash ./filename.sh 2 ./filename.sh
3 the souce ./filename.sh 4 . ./filename.sh
1 and 2 will create a script execution when a new process to execute 3 and 4 execute the script will use the current process to execute (the environment variable environment variable is the current system) (no command to perform a new process called built-in command
134 when executing the script may not have the script execute permission must be executable script execution time 2
Pipe '|' two process between the communications output of the first process as a second process input of a | b | ca outputted as the output b of the input b, c as input (the pipe should avoid the built command
Redirection to save the changes to the standard input and standard output files using a file instead of a keyboard input to the output terminal of the file instead
< Input wc -l </ etc / passwd The <content right side instead of a keyboard input
> Output cover Output >> append output
2 >> redirect the error output to the standard error stream redirection 2
& >> right or wrong redirect output
Variable shell script can have variable variable names consist of alphanumeric digital underscores in a variable name can not be at the beginning of
shell variable is weakly typed not case sensitive to distinguish the types
Use. 1 name = value approximately equals no spaces 2 Read name is read from the user interactive input variables. 3 name LS = value of the variable commands may also be
. 4 name $ = (LS / etc /) value of a variable can also be a command string $ () can be `` anti quotes instead. 5 the let A = 2 the let keyword assignment may also be
6 the value of the variable to be special characters of "or" wrap which should not be used when using let 'single quotes contents of the package do not resolve the variable character string is outputted as
Variable reference $ {} braces {} may be omitted when a string is spliced together with other variables take the value of the string at this time can not be omitted {}
Variable scope default action on the current execution of the shell itself if you want to act on child shell need to use export Export You can use a variable variable when no longer in use unset to delete variables
Environment Variables Environment variables are a variable current user's current unified configuration each user can get shell using the env set you can see the current environment variable
Common environment variable $ PATH for the command search path $ USER username $ UID user the above mentioned id $ PSI configuration terminal prompt is displayed
Predefined variable $? A result of the command to save on 0 correct 1 error $$ current process PID $ 0 Current process name
Position variable $ 0 $ 1 ... $ 9 parameter when the script execution is empty does not exist (2- {$} _ if _ $ 2 is not empty empty Representative Representative $ 2
Environment variable configuration file / etc / profile / etc / bashrc ~ / .bashrc ~ / .bash_bashrc /etc/profile.d/
/ Etc / directory take effect for all users ~ / effect on the current user directory
Performing su - root profile when the execution order of the back / etc / profile overwrite the previous time ~ / .bash_bashrc ~ / .bashrc / etc / bashrc same variable name
Performing su root execute ~ / .bashrc and / etc / bashrc when
Array used
IPTS = (1 2 3) between the array of values separated by a space defined IPTS = (1 2 3)
echo $ {IPTS [@]} all elements
echo $ {# IPTS [@] } the number of display elements
echo $ {IPTS [0]} Display 0th element