Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to execute sh File in linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Linux, there are two ways to command how to run .sh files:

1. Directly. / add the file name .sh. For example, run hello.sh as. / hello.sh [hello.sh must have x permission]

2. Add the file name .sh directly to sh. For example, run hello.sh as sh hello.sh [hello.sh may not have x permission]

Method 1: execute .sh files in the current directory

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

[step 2] add x execution permissions to the .sh file

For example, take hello.sh files as an example

Chmod upright x hello.sh

[step 3]. / execute the .sh file

For example, take the hello.sh file as an example, the terminal executes the following command:

. / hello.sh

The hello.sh file can be executed

[step 4] sh executes the .sh file

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

Method 2: execute .sh file by absolute path

The following three methods are fine

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

Matters needing attention

When executing with ". /" plus the file name .sh, you must add x execution permission to the .sh file.

These are the details of how to execute .sh files in linux. For more information, please pay attention to other related articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report