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

How to run .sh file in linux

(*-*)浩
(*-*)浩Original
2019-11-07 10:44:593257browse

There are two ways to run .sh files under Linux systems. For example, I have a datelog.sh file in the root directory.

How to run .sh file in linux

The first one ( This method requires chmod to make the file meet the execution conditions (x): chmod u x datelog.sh): (Recommended learning: linux operation and maintenance)

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

[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 method (this method does not require the file to have executable permissions to run):

1. Under the file path sh plus the file name, sh datelog.sh

[root@ubitername ~]# sh datelog.sh

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

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

The above is the detailed content of How to run .sh file in 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:How to exit in linuxNext article:How to exit in linux