sh+脚本名称,可以不必事先设定shell的执行权限。因为这个是将test.sh作为参数传给sh(bash)命令来执行的。这时不是test.sh自己来执行,而是被人家调用执行,所以不要执行权限。

[root@iz2ze720onwdpm0gqiky35z 51mn]# ls -lrt test.sh 
-r--r--r-- 1 root root 22 Oct 14 22:34 test.sh
[root@iz2ze720onwdpm0gqiky35z 51mn]# sh test.sh 
hello world

如果直接运行test.sh,就会报权限问题

[root@iz2ze720onwdpm0gqiky35z 51mn]# ./test.sh 
-bash: ./test.sh: Permission denied
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:23 天前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐