Shell Preliminary understanding

Source: Internet
Author: User

Type of shell
    • View the shell program used by the user, the Seventh field in the/etc/passwd file (as if it were the last one, mainly the bash shell)
    • There is also a default shell of/bin/sh, which acts as the default system shell for system shell scripts that need to be used at startup
    • The system default shell is not necessarily consistent with the user (Ubuntu, its default shell is dash shell)
When the shell's parent-child relationship first uses ps-f, it shows two processes, one with an ID of 12546 running the bash shell, and another process (12587) corresponding to the Ps-f

You can continue to create child shells in the child shell. You can exit the child shell through exit. List of processes we can specify a sequence of commands to execute sequentially in one row (;).

Note: PWD current path But this is not a list of processes, for example, there are still only two processes, and no new child shells are generated. The following adds "()" to create a new process. To determine whether to create a child shell, you need to use the environment variable command echo $BASH _subshell (Note: SUBSHELL is a child shell), return 0 There is no child shell, more than 1 is a child shell, the number returned is the number of child shells. Child shells can be called child shell, such as: (PWD; (LS; cd/etc/;p wd; cd; echo $BASH _subshell)), so that two sub-Sheell are called.

    • Child shell Use
     Sleep command, usage: Sleep 10 pauses the session for 10 seconds. Adding the "&" character to the end of the command is to place the command into the background mode, which we can view through ps-f. You can also view all user processes in background mode by using jobs.     The PID of the process can be viewed through jobs-l.     Coproc: It generates a child shell in the background and executes the command in this child shell. Extended syntax ' {} ': A "space" must be added between the first "{" and the command, with a semicolon "after the command ends";     End with a space between the semicolon and the "}".     The cost of generating a child shell is higher and slower. Type-a the implementation of each command, the which command displays only the external command file. Call the external command method to indicate the file.     For example: PWD, you can use/BIN/PWD to implement external commands. History: View a list of recently used commands. 1000 records are usually recorded. "!!"     You can swap out just execute the command and execute.     All commands are saved in ". Bash_history", but you have to exit to save, we can force the save by History-a. We can call this command by "! Number".

    • Command Aliases (alias):
Alias-p to view the current command alias, alias li= ' command ' to create your own alias. such as: Alias Ll= ' Ls-l ', next time can be directly through the "LL" to use.

Shell Preliminary understanding

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.