Home  >  Article  >  Operation and Maintenance  >  How to run .sh file under linux

How to run .sh file under linux

王林
王林Original
2019-12-04 13:31:403177browse

How to run .sh file under linux

1. Directly ./ and add the file name .sh. For example, when running hello.sh, it is ./hello.sh [hello.sh must have x permissions]

2. Direct sh plus the file name .sh, for example, run hello.sh as sh hello.sh [hello.sh does not need x permission]

Method 1: Execute the .sh file in the current directory

Recommended linux video tutorial: linux video tutorial

[Step 1] cd to the directory where the .sh file is located

For example, take the hello.sh file as an example, as shown below

How to run .sh file under linux

[Step 2] Add x execution permissions to the .sh file

For example, take the hello.sh file as an example, chmod u x hello.sh, as shown below

How to run .sh file under linux

[Step 3]./Execute the .sh file

For example, take the hello.sh file as an example, ./hello.sh can execute hello.sh file, as shown below

How to run .sh file under linux

[Step 4]sh executes the .sh file

Take the hello.sh file as an example, sh hello.sh can execute hello .sh file, as shown below

How to run .sh file under linux

Method 2: Execute .sh file with absolute path

The following three methods are available, as shown below:

./home/test/shell/hello.sh
/home/test/shell/hello.sh
sh /home/test/shell/hello.sh

How to run .sh file under linux

Recommended related articles and tutorials: linux tutorial

The above is the detailed content of How to run .sh file under linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is shell in linuxNext article:what is shell in linux