Shell Simple Usage Notes

Source: Internet
Author: User

One, the main use of the Bash Shell in Linux; View the supported shell types available on Linux systems :

Vim/etc/shell

The way to perform shel footsteps:

1. Give footsteps the ability to execute permissions and invoke the script using a relative or absolute path

chmod  755  Test. SH    #赋予该脚本可执行权限. /test. SH                      #以相对路径执行该命令~/test. SH                   #一绝对路径执行该命令

2. Invoke the script with the shell command (the script may not need to execute permissions at this time):

bash  test.js     #使用bash Shell executes sh      test.js     #使用sh执行

Note: The shell script is #! /bin/bash begins by saying that the shell script is written (equivalent to PHP's <?php?>)

Second, the Shell History Command view

Run: History to see the commands that have been used under the user (through the up and down arrows to see the previous or next command executed)

Use Vim ~/.bash_history to view historical commands that have been maintained

You can view the maximum number of saved history entries by viewing the/etc/profile

By:!n the nth command of the repeatable history record

By:!str can repeat the last history command starting with Str

C. Shell definition aliases

The  aliasls"ls-l"   #定义ls-L is named LS, and is actually executed when LS is executed ls-l

Configuration of aliases (configuration aliases are permanently active):

Edit ~/.BASHRC

Iv. output Redirection

Standard output/dev/stdin 0 keyboard

Standard output/dev/stdout 1 display

Standard error Output/dev/strerr 2 display

ls > AA cover to AA

LS >> AA append to AA

LS hahah 2>aa output error to AA (no spaces on both sides of the error output)

LS &> AA will output correct and error to AA

V. Execution of multiple orders

ls Date           #中断中输入后会顺序执行该3条命令  ls  Date       #前一条正确执行后, execute LS AAA on the following line   | |  Date        #前一条命令错误执行, the next command executes the lsechoecho no          #ls  AAA correctly executes output Yes, executes error output nolsgrep  etc    #前一条命令的执行结果 as the execution condition of the latter command

Vi. variables

1. Variable classification

    • Local variables
    • Environment variables
    • Positional parameter variables
    • Pre-defined variables

Environment variable configuration file:

/etc/profile

/etc/bashrc

~/.bashrc

~/.bash_profile

The first two take effect for all users, and the latter two for the specified user

Shell Simple Usage Notes

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.