job.sh is readable but has no execute permission.
Run its contents as a script in a new Bash process.
Which command is appropriate?
bash job.sh starts Bash and reads job.sh as input, so the script file itself does not need the execute bit.
Detailed explanation
exec job.shIncorrect. exec job.sh treats the file as an executable and also requires execute permission.
./job.shIncorrect. Direct execution of ./job.sh requires the execute bit.
. job.shIncorrect. . job.sh sources the file in the current shell rather than starting a new Bash.
bash job.shCorrect. bash job.sh reads the file as Bash input.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); printf 'echo ran\n' >"$tmp/job.sh"; chmod 600 "$tmp/job.sh"; bash "$tmp/job.sh"; rm -rf "$tmp"Expected result
ranKey points
- Bash reads the script
- Read permission is needed
- Direct execution requires x permission
Notes
- Environment: Bash 5.x / 一時スクリプト
- Use disposable shell sessions and harmless commands for experiments.
- Shell behavior can depend on Bash options and distribution defaults.
Foundation review
Place the operation
A readable script can be interpreted by an explicitly launched Bash even when its execute bit is absent.
Check the side effect
Keep the distinction between interpreter read access and kernel direct-execution checks.