为什么可能;mkdir-p";导致Bash权限错误?
如果使用为什么可能;mkdir-p";导致Bash权限错误?,bash,permissions,mkdir,Bash,Permissions,Mkdir,如果使用mkdir-p创建目录,则会导致脚本出现问题 $mkdir-p test2/test2 $cd test2/test2 $echo'#/垃圾箱/垃圾箱 >回声你好 美元/你好.sh bash:./hello.sh:权限被拒绝 这与mkdir无关。您只是没有授予hello.sh可执行权限。您需要以下内容: chmod +x hello.sh 这与mkdir无关。您只是没有授予hello.sh可执行权限。您需要以下内容: chmod +x hello.sh 检查您的权限 检查目录和脚本本
mkdir-p
创建目录,则会导致脚本出现问题
$mkdir-p test2/test2
$cd test2/test2
$echo'#/垃圾箱/垃圾箱
>回声你好
美元/你好.sh
bash:./hello.sh:权限被拒绝
这与mkdir
无关。您只是没有授予hello.sh
可执行权限。您需要以下内容:
chmod +x hello.sh
这与
mkdir
无关。您只是没有授予hello.sh
可执行权限。您需要以下内容:
chmod +x hello.sh
检查您的权限
检查目录和脚本本身的权限。那里可能有问题,尽管可能性不大
ls -lad test2/test2
ls -l test2/test2/hello.sh
如果您的权限由于某种原因设置不正确,则始终可以对mkdir使用--mode标志。有关更多信息,请参阅chmod(1)和mkdir(1)
直接执行文件
您可以直接使用Bash执行脚本,而不是依赖shebang行或可执行位,只要当前用户可以读取该文件。例如:
bash test2/test2/hello.sh
chmod 755 test2/test2/hello.sh
更改文件权限
如果可以在使用Bash显式调用时执行该文件,那么只需确保文件设置了execute位。例如:
bash test2/test2/hello.sh
chmod 755 test2/test2/hello.sh
检查您的权限
检查目录和脚本本身的权限。那里可能有问题,尽管可能性不大
ls -lad test2/test2
ls -l test2/test2/hello.sh
如果您的权限由于某种原因设置不正确,则始终可以对mkdir使用--mode标志。有关更多信息,请参阅chmod(1)和mkdir(1)
直接执行文件
您可以直接使用Bash执行脚本,而不是依赖shebang行或可执行位,只要当前用户可以读取该文件。例如:
bash test2/test2/hello.sh
chmod 755 test2/test2/hello.sh
更改文件权限
如果可以在使用Bash显式调用时执行该文件,那么只需确保文件设置了execute位。例如:
bash test2/test2/hello.sh
chmod 755 test2/test2/hello.sh