Bird
0
0

Find the bug in this shell script snippet intended to disable SSH on Raspberry Pi: ```bash if [ $disable_ssh = true ] then systemctl stop ssh fi ```

medium📝 Debug Q7 of 15
Raspberry Pi - Security and Deployment
Find the bug in this shell script snippet intended to disable SSH on Raspberry Pi: ```bash if [ $disable_ssh = true ] then systemctl stop ssh fi ```
AMissing semicolon after if condition
BVariable $disable_ssh is not quoted
CWrong command to stop SSH
DNo fi to close if statement
Step-by-Step Solution
Solution:
  1. Step 1: Check shell variable usage

    Variables should be quoted to avoid errors if empty or containing spaces.
  2. Step 2: Verify other syntax elements

    Semicolon is optional before then; 'systemctl stop ssh' is correct; 'fi' is present.
  3. Final Answer:

    Variable $disable_ssh is not quoted -> Option B
  4. Quick Check:

    Shell bug = Unquoted variable [OK]
Quick Trick: Quote variables in shell scripts to avoid errors [OK]
Common Mistakes:
MISTAKES
  • Forgetting quotes around variables
  • Adding unnecessary semicolons
  • Using wrong commands to stop services

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes