Linux shell understanding

First, start with exit shell

1. Modify the start of the shell in / etc / passwd seventh field modification

2. Start by entering the shell / bin / bash command line

3.exit exit the shell

Second, the relationship between father and son shell

1. shell shell produced when the terminal is opened is called the parent shel, prompt input / bin / bash shell produced is called the child

   Relationship between the two can be displayed by a command or ps -f ps --forest, the sub-shell can also generate its own sub-shell, this time corresponds to their parent shell

2. The parent shell environment variable part will be copied to the child shell

Third, the process list

1.  pwd; LS; CD / etc; pwd; CD; pwd; LS referred Liu Biao command, the command in the middle with ';' separator, the command execution sequence

2. (pwd; LS; cd / etc; pwd; cd; pwd; LS) process known as Liu Biao, more outside the parentheses is the work group

3. The process generated a list zishell to perform the corresponding command, the list of commands executed by the parent shell

4. A list of commands increase outside the brackets is another work group, the parent does not need to create a sub-shell shell

5.echo $ BASH_SUBSHELL returns 0 indicates no generation sub-shell, and non-zero return is generated, the number of digital representation of a nested shell. These can be placed in the detection list

Fourth, background mode: run the command execution does not take up shell continue to enter other commands

1. The command into the background mode command & sleep 10 & e.g.

2. The background job, the first number is the background job number, the second is the PID

3. Display background job jobs, jobs can be displayed command and implementation (such as running) Options: -l long list display

   + Means running, - expressed its readiness to run

4. Process the list can be placed in Example background mode  (sleep 2; echo $ BASH_SUBSHELL; sleep 2) &

5. coroutine: Background create a sub-shell and executed command   coproc processname [command]

   Example  coproc My_Job {sleep 10;}  This is the extended syntax, and command attention spaces between the braces, and the command is followed;

Five, shell built-in commands and external commands

1. The external command, also known as file system commands, program exists outside the shell, located in / bin, / usr / bin, / sbin, / usr / sbin in

2. The internal command is part of the shell program

3.which command output of the external command position type -a command can also output external command position

Will create a child process is executed 4. external command, known as derivatives

The built-in command does not need to use the child process, the tool is part of the embodiment of the shell cd exit, type -a command is determined whether built

Sixth, convenient command

1.history show command history, save in .bash_history, the deposit when the shell exits, the use of history -a compulsory written before exiting

   history -n forced to read the updated history list

2 ! ! Just call up the commands used to perform,! number call up a history list of commands

3. command aliases alias, alias -p show all aliases; create aliases alias text = 'command'

   Example   Alias = Li '-Li LS'  , is only present in the shell and the effective start of the script

 

发布了5 篇原创文章 · 获赞 3 · 访问量 4236

Guess you like

Origin blog.csdn.net/weixin_42686673/article/details/104600715