关于 sh 和 ./

Shengyu Liu

我想如果我想用来./执行脚本,我必须先运行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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章