Permission issues, not able to run script as root

谁都会走 提交于 2019-12-01 06:25:43

问题


I am running a shell script(Script.sh) which, itself, is calling other shell scripts( Script2.sh, Script3.sh ...etc). I logged in as a root user and have given execution permission to all the scripts. But on when I execute "ls -l" the scripts still dont have execution permissions displayed on file attributes column. "Script.sh" runs by following syntax:

root@freescale $ sh Script.sh

But this script is not able to execute other scripts(Script2.sh, Script3.sh) being called by it. Error is reported as "Permission denied"

I already gave execution permission by chmod command but then also neither the permissions are changing nor the scripts(Script2.sh, Script3.sh ..) are executing.

I hope this error is due to the reason that Script2.sh are called in Script3.sh as:

./Script2.sh
./Script3.sh

And if I write it as : sh Script2.sh It executes but doesn't able to execute other script which are called inside Script2.sh and reports same error as "Permission Denied"


回答1:


Make sure that your partition is not mounted with the noexec flag (which - as the name suggests - prevents making any files executable)




回答2:


Kindly make sure the permission and ownership for the script.sh file, also try

 # chmod 755 script.sh
 # chown root.root script.sh

Thanks.



来源:https://stackoverflow.com/questions/17421842/permission-issues-not-able-to-run-script-as-root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!