How Linux Shell executes

Source: Internet
Author: User

There are two ways that Linux shell executes

Shell scripts start with #!/bin/bash, and the shell is executed with the first row checked and executed internally in the following ways:

$/bin/bash script.sh

1. Execute with SH.

$sh script.sh #脚本位于当前目录下

Or

$sh/home/path/script.sh #使用完整路径

2. Run the script independently.

You need to have executable permissions that can be set in the following way

$chmod a+x script.sh

Or

$chmod 755 script.sh

This can then be done in the following ways:

$./script.sh #./represents the current directory

Or

$/home/path/script.sh #使用完整路径

--------------------------------------------------------------------------------

Appendix: chmod Command

chmod [-CFVR] [--help] [--version] Mode file ...

chmod owner Group World FileName

4–read (R)
2–write (W)
1–execute (x)

7 = 4+2+1 (Read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (Read/execute)
4 = 4 (Read)
3 = 2+1 (Write/execute)
2 = 2 (write)
1 = 1 (execute)

+ indicates an increase in permissions,-represents a cancellation permission, = Represents a unique set of permissions

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.