Linux shell su: failed to execute,permission denied

su - root -s $SHELLPATH

root users will report an error when executing, and permission denied

pops up.

but use

directly
source $SHELLPATH

can be executed

what is the reason for this?

Thank you.

Jun.22,2021

running the script directly requires the file to have execute permission for the current user. The source command is not required, and source only needs read permission.

you can use

chmod +x yourscript.sh

to set execution permissions

Menu