我想如果我想用来./
执行脚本,我必须先运行chmod +x file
。但是为什么我可以在sh file
没有chmod
命令的情况下使用它来执行它?并不sh
需要任何执行权限?
sh
有执行权限。那么它基本上是一个破折号的符号链接。
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Feb 17 2016 /bin/sh -> dash
并且 dash 具有执行权限:
$ ls -l /bin/dash
-rwxr-xr-x 1 root root 154072 Feb 17 2016 /bin/dash
破折号所要做的就是解析脚本,因此文件需要可读。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句