Linux notes: Shell basics and Bash's basic features

Source: Internet
Author: User
Tags aliases clear screen

Shell's advantage: You can call Linux system commands directly

Basic syntax for shell scripts:
Script name ends with. sh
The first action of the program #!/bin/bash, tell the system this is a shell script
With # as a comment
How shell scripts are executed:
Give script execution permission first, chmod;
It is called directly with an absolute or relative path (because the shell is an executable program, so it can be called directly with a path), such as:
/home/hqqq/test/t.sh

Basic features of bash:

One, Tab key file and command completion:
If there is only one match, it can be auto-complete once, and if there are more than one match, press two tab to prompt.

Second, the command alias:
Command alias query:
Alias
To set a command alias:
Alias aliases = ' Original command '

To delete an alias:
Unalias aliases

Order of command execution:
1. Executing commands with paths
2. Aliases
Internal command for 3.Bash
4. The first command found by the directory in the environment variable

The way the command line is set will only take effect temporarily, making the alias permanent for writing to the configuration file:
/user Home Directory/.BASHRC

Third, bash common shortcut keys
CTRL + C forces the current command to terminate
Ctrl+u the command before deleting or cutting the cursor
Ctrl+l Clear Screen
Ctrl+y Paste Ctrl+u Cut content
Ctrl+d exiting the current terminal

Iv. Input and output redirection
Standard input: Keyboard. File Descriptor: 0
Standard output: Monitor. File Descriptor: 1
Standard error Output: Monitor. File Descriptor: 2

Standard output redirection:

Five, multiple order execution and pipe character

Sequential execution of MULTIPLE commands:

Pipe character:

Command 1 | Command 2 #命令1的正确输出作为命令2的操作对象

Six, wildcards and other special characters

Linux notes: Shell basics and Bash's basic features

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.