Challenge - 5 Problems
Headless Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Raspberry Pi headless Wi-Fi setup script?
Consider this script snippet that configures Wi-Fi on a Raspberry Pi without a monitor. What will be the output after running it?
Raspberry Pi
import os ssid = "HomeNetwork" password = "mypassword" wpa_supplicant_conf = f""" ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=US network={{ ssid=\"{ssid}\" psk=\"{password}\" key_mgmt=WPA-PSK }} """ with open("/etc/wpa_supplicant/wpa_supplicant.conf", "w") as f: f.write(wpa_supplicant_conf) print("Wi-Fi configuration file created.")
Attempts:
2 left
💡 Hint
Think about file writing permissions on Raspberry Pi OS.
✗ Incorrect
The script writes the Wi-Fi config file with correct syntax and prints the success message. If run with proper permissions, it succeeds.
🧠 Conceptual
intermediate1:30remaining
Which file enables SSH access on a Raspberry Pi in headless mode?
When preparing a Raspberry Pi SD card for headless setup, which file must be created or modified to enable SSH access on boot?
Attempts:
2 left
💡 Hint
This file is placed in the boot partition and has no extension.
✗ Incorrect
Creating an empty file named 'ssh' in the boot partition enables SSH on first boot.
🔧 Debug
advanced2:30remaining
Why does this headless Wi-Fi setup script fail to connect?
This Python script writes a wpa_supplicant.conf file but the Raspberry Pi does not connect to Wi-Fi. Identify the bug.
Raspberry Pi
ssid = "MyWiFi" password = "pass1234" wpa_conf = f""" network={{ ssid="{ssid}" psk="{password}" key_mgmt=WPA-PSK }} """ with open("/etc/wpa_supplicant/wpa_supplicant.conf", "w") as f: f.write(wpa_conf) print("Config written")
Attempts:
2 left
💡 Hint
Check the indentation inside the network block.
✗ Incorrect
Wi-Fi config requires ssid and psk lines to be indented inside network block for wpa_supplicant to parse correctly.
📝 Syntax
advanced1:30remaining
What error does this Raspberry Pi headless setup script produce?
What error will this Python code produce when run on Raspberry Pi to create wpa_supplicant.conf?
Raspberry Pi
with open('/etc/wpa_supplicant/wpa_supplicant.conf', 'w') as f f.write('network={ssid="MyWiFi" psk="pass1234"}')
Attempts:
2 left
💡 Hint
Check the syntax of the with statement.
✗ Incorrect
The with statement is missing a colon at the end, causing a SyntaxError.
🚀 Application
expert2:00remaining
How many lines will the Raspberry Pi read from wpa_supplicant.conf after this script runs?
This script writes a wpa_supplicant.conf file for headless Wi-Fi setup. How many lines will the file contain?
Raspberry Pi
conf = '''ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=GB network={ ssid="OfficeWiFi" psk="securepass" key_mgmt=WPA-PSK } ''' with open('/etc/wpa_supplicant/wpa_supplicant.conf', 'w') as file: file.write(conf)
Attempts:
2 left
💡 Hint
Count all lines including blank lines in the triple-quoted string.
✗ Incorrect
The string has 9 lines including blank lines and closing braces.