linux - 权限问题,无法以 root 身份运行脚本

标签 linux shell file-permissions

我正在运行一个 shell 脚本 (Script.sh),它本身正在调用其他 shell 脚本 ( Script2.sh、Script3.sh 等)。我以 root 用户身份登录,并已授予所有脚本的执行权限。但是当我执行“ls -l”时,脚本仍然没有在文件属性列上显示的执行权限。 “Script.sh”按以下语法运行:

root@freescale $ sh Script.sh

但是这个脚本不能执行它调用的其他脚本(Script2.sh, Script3.sh)。错误报告为“权限被拒绝”

我已经通过 chmod 命令授予了执行权限,但权限既没有改变,脚本(Script2.sh、Script3.sh ..)也没有执行。

我希望这个错误是由于在 Script3.sh 中调用 Script2.sh 的原因造成的:

./Script2.sh
./Script3.sh

如果我把它写成: sh脚本2.sh 它执行但无法执行在 Script2.sh 中调用的其他脚本,并报告与“权限被拒绝”相同的错误

最佳答案

确保您的分区没有挂载noexec标志(顾名思义,它会阻止任何文件可执行)

关于linux - 权限问题,无法以 root 身份运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17421842/

相关文章:

linux - Shell脚本,失败则停止运行

cocoa - 在 cocoa 中 : How to set permission to read/write to a folder?

linux - 在 linux 中获取 % 之前的数字的命令

linux写(): does it try to write as many bytes as possible?

linux - Geany:如何查找和计数?

linux - 向 ghostscipt 运行配置添加一个允许的路径

bash - 为什么这个别名在 .bash_profile 脚本中不起作用?

python - 在 Python 中通过 `subprocess.run` 调用 g++ 导致可执行文件中的 "exec format error"

iis - 加载配置文件 : Failed to start monitoring changes to '\\share' 时出错

python - os.access 返回 True,但文件不可写