Basic Linux Shell knowledge

Source: Internet
Author: User
◆ Shell Basics 1. view the available shell2 on the computer by using catetcshells. write a shell and save it as firstscript! BinbashThisisatestecho-n

◆ Basic Shell knowledge

1. cat/etc/shells

View the available shell on the computer

2. write a shell and save it as firstscript.

#! /Bin/bash # This is a test. echo-n Your current directory is: pwdecho $ HOMEecho Your current directory is: pwd # END.

3. run firstscript

$/Bin/bash firstscript

If the file cannot be found, use pwd to view the current directory.

$/Bin/bash pwd/firstscript

The current running result is displayed.

4. you can modify firstscript to execute

$ Chmod a + x firstscript

Enter $./firstscript.

The above shell is not exchanged, so we can interact as follows:

#! /Bin/shecho-n Please input your ID: read id_varecho-n Please input your password: read passwordecho User ID = $ id_varecho password = $ passwordif [$ password = "admin"]; thenecho "password is right" elseecho "password is wrong" fi

Run the same command as before and test it by yourself.

◆ Meaning represented by the "" and "--" symbols in the command line

If the row ends, it indicates that the row is not over yet. the following line means the same as the row.

-- Is the start of the option. Generally, the option of a letter starts with-, and the option of multiple letters starts.

"" May be omitted if it is a carriage return without line breaks, but it cannot be omitted if it is another character.

"" Tells the system that the character followed is the original intent, not a command. for example, if a file name contains spaces, add "" before the space.

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.