How to run .sh file in linux

(*-*)浩
Release: 2019-11-07 10:44:59
Original
3315 people have browsed it

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
Copy after login

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

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

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template