Challenge - 5 Problems
Executable Script Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this command sequence?
You have a script named
What changes will you see in the second
myscript.sh without execute permission. You run these commands:ls -l myscript.shchmod +x myscript.shls -l myscript.shWhat changes will you see in the second
ls -l output compared to the first?Bash Scripting
ls -l myscript.sh chmod +x myscript.sh ls -l myscript.sh
Attempts:
2 left
💡 Hint
Think about what the 'x' means in file permissions and what chmod +x does.
✗ Incorrect
The chmod +x command adds execute permission to the file for user, group, and others. This is shown as 'x' in the permission string when you run ls -l. It does not change file size, owner, or name.
📝 Syntax
intermediate1:30remaining
Which command correctly makes a script executable for the owner only?
You want to make a script named
run.sh executable only by the file owner, not by group or others. Which command achieves this?Attempts:
2 left
💡 Hint
Remember that 'u' means user (owner), 'g' group, 'o' others, and 'a' all.
✗ Incorrect
chmod u+x adds execute permission only for the user (owner). chmod +x or chmod a+x adds execute permission for all (user, group, others). chmod og+x adds execute for group and others, not user.
🔧 Debug
advanced2:30remaining
Why does this script fail to run even after chmod +x?
You have a script
script.sh with execute permission set by chmod +x script.sh. When you run ./script.sh, you get bash: ./script.sh: /bin/bash^M: bad interpreter: No such file or directory. What is the cause?Attempts:
2 left
💡 Hint
The ^M character often appears when files are edited on Windows and run on Linux.
✗ Incorrect
The ^M character is a carriage return from Windows line endings (CRLF). Linux expects LF only. This causes the interpreter path to be invalid. Converting the file to Unix line endings fixes this.
🚀 Application
advanced2:00remaining
How to make all scripts in a folder executable for the owner only?
You have many scripts in a folder
scripts/. You want to make all files ending with .sh executable only by the owner. Which command will do this correctly?Attempts:
2 left
💡 Hint
Think about which users should get execute permission and how to specify that in chmod.
✗ Incorrect
chmod u+x adds execute permission only for the owner (user) on all .sh files in scripts/. chmod +x or a+x adds execute for all users. chmod og+x adds execute for group and others only.
🧠 Conceptual
expert2:30remaining
What is the effect of
chmod 4755 script.sh?You run
chmod 4755 script.sh on a script. What does the '4' in the permission number do?Attempts:
2 left
💡 Hint
The first digit in chmod numeric mode sets special permissions like setuid, setgid, and sticky bit.
✗ Incorrect
The leading '4' sets the setuid bit. This means when the script runs, it runs with the permissions of the file owner, not the user who runs it. This is often used for programs needing elevated privileges.