Recall & Review
beginner
What does the command
chmod +x script.sh do?It adds execute permission to the file
script.sh, allowing it to be run as a program.Click to reveal answer
beginner
Why do you need to make a script executable before running it?
Because the operating system requires execute permission to run a file as a program. Without it, you can only read or edit the script, not run it directly.
Click to reveal answer
intermediate
What is the difference between
chmod +x script.sh and chmod 755 script.sh?chmod +x adds execute permission to the existing permissions. chmod 755 sets read, write, and execute for owner and read and execute for group and others explicitly.Click to reveal answer
beginner
How can you check if a script is executable?
Use
ls -l script.sh. If you see an x in the permission string (e.g., -rwxr-xr-x), it means the script is executable.Click to reveal answer
beginner
What happens if you try to run a script without execute permission?
You will get a 'Permission denied' error if you try to run it directly. However, you can still run it by calling the interpreter explicitly, like
bash script.sh.Click to reveal answer
What does
chmod +x myscript.sh do?✗ Incorrect
The command adds execute permission to the script, allowing it to be run.
Which command shows if a file is executable?
✗ Incorrect
The
ls -l command lists file permissions, showing if execute permission is set.If a script is not executable, how can you still run it?
✗ Incorrect
Calling the interpreter explicitly runs the script without needing execute permission.
What permission does
chmod +x add?✗ Incorrect
The
+x flag adds execute permission to the file.What error appears if you run a script without execute permission?
✗ Incorrect
Trying to run a non-executable script directly results in a 'Permission denied' error.
Explain why and how you make a script executable in bash.
Think about what the system needs to allow running a file as a program.
You got /3 concepts.
Describe how to check if a script is executable and what the permission string looks like.
Look at the file permissions shown by ls.
You got /3 concepts.