ITPub博客

首页 > > > linux shell执行方式

linux shell执行方式

作者:longmanma 时间:2020-02-19 23:33:55 0 删除 编辑

linux shell执行有两种方式

shell脚本以#!/bin/bash开头,执行shell时先检查首行,在内部以下列方式执行:

$/bin/bash script.sh 

1. 使用sh执行。

   $sh script.sh #脚本位于当前目录下

或者

   $sh /home/path/script.sh #使用完整路径

2. 独立运行脚本。

需要具备可执行权限,可以通过下面的方式设置

$chmod a+x script.sh

或者

$chmod 755 script.sh

然后可以通过下列方式执行:

$./script.sh #./表示当前目录

或者

$ /home/path/script.sh #使用完整路径

--------------------------------------------------------------------------------

附录:chmod 命令

chmod [-cfvR] [--help] [--version] mode file...

chmod owner group world FileName

● 4 – read (r)
● 2 – write (w)
● 1 – execute (x)

7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)

+ 表示增加权限、- 表示取消权限、= 表示唯一设定权限

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2730/viewspace-3158639/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-12-18

  • 博文量
    492
  • 访问量
    11996