Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of running .sh file by linux

Shulou Source: shulou.com Published: 2022-06-02 21:55:45 09月12日 Update

This article shows you how to run linux.sh files. The code is concise and easy to understand. It will definitely make your eyes shine. I hope you can gain something from the detailed introduction of this article.

There are two ways to run a.sh file on Linux. For example, I have a datelog.sh file in my root directory.

The first method (this method requires chmod to make the file executable (x): chmod u+x datelog.sh):

1. Under any path, enter the absolute path of the file/root/datelog.sh to execute the file (of course, if permissions permit).

[root@ubitername ~]# /root/datelog.sh

2. cd to the directory of the datelog.sh file, and then execute./ datelog.sh

[root@ubitername ~]# cd /root[root@ubitername ~]# ./ datelog.sh

The second option (which does not require executable permissions on the file to work):

1. Add the file name to sh under the file path, sh datelog.sh

[root@ubitername ~]# sh datelog.sh

2. Under any path, sh plus the file path and file name: sh /root/datelog.sh

[root@ubitername ~]# cd /etc[root@ubitername ~]#sh/root/datelog.sh This is how linux runs.sh files. Have you learned anything or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.

Tags: File path run method method skill permission directory knowledge concise concise below code content name name that is situation article more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Tech Info macOS Redmi Huawei