Recognize and learn Bash

Source: Internet
Author: User

We know that the management of the entire computer hardware is actually the kernel of the operating system (kernel), and the kernel is generally required to protect, so we generally users can only through the shell to communicate with the kernel, let the kernel do what we want to do the work. So how many shells does the system have available? Why are we using the shell? --we have to communicate our input commands to the kernel through the "shell" so that the kernel can control the hardware to work correctly. The Shell's function is just an interface to the user's operating system, which can invoke other software.

Several benefits of using the shell:

    • Shell of the command line interface: Everyone is the same. The bash used by almost every distribution is the same. This way you can convert different distribution at will.
    • Remote administration: Faster command line. Faster and less likely to be short-term or information-draining issues.

There are already many versions of the shell available, and bash is one of the most important programs in the GNU program and is now the standard shell for distributions. The advantages of bash are:

    • Command memory Function: (history) use the UP and DOWN ARROW keys on the command line to find the front/rear input commands;
    • command and file completion function: [Tab] key complete. [Tab] After the first word of a string of commands, the command is complete, and [tab] is appended to the second word of a sequence of commands to fill the file. You may want to press the [Tab] button a few times under bash shell.
    • Command alias settings. Alias lm = ' Ls-al '
    • Program Scripts
    • The use of wildcard characters *.

The variable function of the shell.

    • echo ${path}/${home} will show you what the current environment variable is.
    • There must be no spaces before and after the equals sign.
    • "" The contents of the variable can still be retained, but the contents of the single quotation mark are only treated as a generic string.
    • Examples of the use of variable settings: If you have a common working directory name: "/cluster/server/work/xxx/001/", you can use variable assignment to achieve the purpose of simplifying the directory.
      • work= "/cluster/server/work/xxx/001/"
      • CD $work
      • When you want to enter the working directory, you can use the CD $work directly.

The function of the environment variable.

    • Use env to view environment variables and common environment variable descriptions.
      • Home: Represents the user's home folder.
      • Shell: Tell us which shell program the current environment is using. Linux uses/bin/bash by default
      • Path: Paths for performing file lookups

The path and command lookup order.

    • Executes a command with a relative/absolute path, such as "/bin/ls" or "./ls";
    • Executed by alias to find the command;
    • Executed by Bash's built-in (builti) command;
    • Find the first command to execute in the order of a $path this variable.

Bash's default key combination.

    • CTRL + C terminates the current command
    • Ctril+d input End (EOF), such as when the message ends
    • Ctrl+m is Enter
    • Ctrl+s pause the output of the screen
    • Ctril+q Restore the output of the screen
    • CTRL + Z pause the current command

Piping command (pipe).

    • The output data will appear when the Bash command executes. If this group of data has to go through several formalities before we can get the format we want, we need to use pipe pipe command.
    • Pipeline Command Use | As a defining symbol. "|" The ability to handle only the correct information from the previous command, that is, standard out, is not directly handled for standard error.

Recognize and learn Bash

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.