Challenge - 5 Problems
Bash Automation 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 Bash script?
Consider this Bash script that automates a simple task of listing files and counting them:
Bash Scripting
#!/bin/bash count=$(ls | wc -l) echo "Number of files: $count"
Attempts:
2 left
💡 Hint
The script counts files in the current directory using ls and wc commands.
✗ Incorrect
The script runs ls to list files, pipes output to wc -l to count lines, then prints the count. The output depends on actual files present.
🧠 Conceptual
intermediate1:30remaining
Why is Bash scripting useful for Linux task automation?
Which of the following best explains why Bash scripting is commonly used to automate Linux tasks?
Attempts:
2 left
💡 Hint
Think about how Bash scripts use existing Linux commands.
✗ Incorrect
Bash scripting allows chaining and combining many Linux commands to automate repetitive tasks efficiently.
🔧 Debug
advanced2:00remaining
What error does this Bash script produce?
Look at this script intended to automate file backup but it has a bug:
Bash Scripting
#!/bin/bash backup_dir=/backup mkdir -p $backup_dir cp /home/user/*.txt $backup_dir
Attempts:
2 left
💡 Hint
Consider permissions when creating directories outside your home folder.
✗ Incorrect
Creating /backup usually requires root permissions. Without them, mkdir fails with permission denied error.
🚀 Application
advanced2:30remaining
Which script snippet correctly automates checking if a service is running and restarts it if not?
You want to automate checking if 'nginx' service is active and restart it if it is not. Which snippet does this correctly?
Attempts:
2 left
💡 Hint
Check the correct use of systemctl is-active with --quiet and conditional logic.
✗ Incorrect
Option A correctly uses systemctl is-active --quiet to check status silently and restarts if not active.
🧠 Conceptual
expert2:00remaining
What is the main advantage of using Bash scripting over manual command execution for Linux task automation?
Choose the best explanation for why Bash scripting is preferred for automating Linux tasks instead of typing commands manually each time.
Attempts:
2 left
💡 Hint
Think about automation and repetition benefits.
✗ Incorrect
Bash scripts can be scheduled (e.g., with cron) to run automatically, saving time and avoiding errors from manual repetition.