Bird
Raised Fist0
Raspberry Piprogramming~10 mins

Headless deployment setup in Raspberry Pi - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable SSH on Raspberry Pi for headless setup.

Raspberry Pi
sudo systemctl [1] ssh
Drag options to blanks, or click blank then click option'
Aenable
Bdisable
Cstop
Drestart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'disable' instead of 'enable' disables SSH access.
Using 'stop' or 'restart' only affects current session, not startup.
2fill in blank
medium

Complete the command to create an empty file named 'ssh' in the boot directory to enable SSH on first boot.

Raspberry Pi
touch /boot/[1]
Drag options to blanks, or click blank then click option'
Awpa_supplicant.conf
Bconfig.txt
Ccmdline.txt
Dssh
Attempts:
3 left
💡 Hint
Common Mistakes
Creating 'config.txt' or 'cmdline.txt' does not enable SSH.
Using 'wpa_supplicant.conf' is for Wi-Fi setup, not SSH.
3fill in blank
hard

Fix the error in the command to add Wi-Fi credentials to the Raspberry Pi's wpa_supplicant.conf file.

Raspberry Pi
sudo nano /etc/wpa_supplicant/[1]
Drag options to blanks, or click blank then click option'
Anetwork.conf
Binterfaces
Cwpa_supplicant.conf
Dwlan0.conf
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'network.conf' or 'interfaces' are incorrect for this purpose.
Editing 'wlan0.conf' is not standard for Raspberry Pi Wi-Fi setup.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each device name to its IP address if the device is active.

Raspberry Pi
active_devices = {device: info[1] for device, info in devices.items() if info['status'] [2] 'active'}
Drag options to blanks, or click blank then click option'
A['ip']
B==
C!=
D.get('ip')
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' reverses the condition.
Using '.get('ip')' is valid but not the expected syntax here.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase device names to their IPs if the IP is not empty.

Raspberry Pi
filtered = { [1]: [2] for [3], info in devices.items() if info['ip'] != '' }
Drag options to blanks, or click blank then click option'
Adevice.upper()
Binfo['ip']
Cdevice
Dinfo
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'info' as key or value incorrectly.
Using 'device' instead of 'device.upper()' for keys.

Practice

(1/5)
1. What is the main purpose of a headless deployment setup on a Raspberry Pi?
easy
A. To connect multiple Raspberry Pis in a cluster
B. To install a graphical user interface on the Raspberry Pi
C. To control the Raspberry Pi without a monitor, keyboard, or mouse
D. To update the Raspberry Pi firmware automatically

Solution

  1. Step 1: Understand headless setup concept

    Headless setup means using the Raspberry Pi without directly connecting a monitor, keyboard, or mouse.
  2. Step 2: Identify the main purpose

    This setup allows remote control, usually via SSH, without extra devices attached.
  3. Final Answer:

    To control the Raspberry Pi without a monitor, keyboard, or mouse -> Option C
  4. Quick Check:

    Headless = Remote control without peripherals [OK]
Hint: Headless means no monitor or keyboard needed [OK]
Common Mistakes:
  • Thinking headless means adding a GUI
  • Confusing headless with networking multiple Pis
  • Assuming it updates firmware automatically
2. Which file must you add to the Raspberry Pi's boot partition to enable SSH on headless setup?
easy
A. ssh_enable
B. ssh.txt
C. enable_ssh.conf
D. ssh

Solution

  1. Step 1: Recall SSH enabling method

    To enable SSH on boot, you add an empty file named exactly 'ssh' (no extension) to the boot partition.
  2. Step 2: Identify correct filename

    Only the file named 'ssh' without extension works; others are ignored.
  3. Final Answer:

    ssh -> Option D
  4. Quick Check:

    Empty file named 'ssh' enables SSH [OK]
Hint: Add empty file named 'ssh' to boot partition [OK]
Common Mistakes:
  • Adding file with extension like .txt
  • Using wrong filenames like ssh_enable
  • Not adding any file at all
3. Given this wpa_supplicant.conf content added to the boot partition, what will happen after the Raspberry Pi boots?
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
  ssid="HomeWiFi"
  psk="mypassword"
  key_mgmt=WPA-PSK
}
medium
A. The Pi will fail to connect because the country code is missing
B. The Pi will connect to the Wi-Fi network named 'HomeWiFi' automatically
C. The Pi will connect but require manual password entry
D. The Pi will connect to any open Wi-Fi network nearby

Solution

  1. Step 1: Analyze wpa_supplicant.conf content

    The file includes correct country code, control interface, and network block with SSID and password.
  2. Step 2: Understand Wi-Fi connection behavior

    With this config, the Pi will automatically connect to the specified Wi-Fi network on boot.
  3. Final Answer:

    The Pi will connect to the Wi-Fi network named 'HomeWiFi' automatically -> Option B
  4. Quick Check:

    Valid wpa_supplicant.conf = Auto Wi-Fi connect [OK]
Hint: Correct wpa_supplicant.conf auto connects Wi-Fi [OK]
Common Mistakes:
  • Thinking country code is optional and causes failure
  • Assuming manual password input is needed
  • Believing it connects to any open network
4. You added the 'ssh' file and 'wpa_supplicant.conf' to the boot partition but cannot SSH into your Raspberry Pi after boot. What is the most likely mistake?
medium
A. The 'ssh' file has a .txt extension, so SSH is not enabled
B. The Raspberry Pi does not support headless setup
C. You forgot to connect a monitor and keyboard
D. The Pi boots too fast to accept SSH connections

Solution

  1. Step 1: Check common headless setup errors

    A common error is naming the 'ssh' file with an extension like '.txt', which disables SSH enabling.
  2. Step 2: Evaluate other options

    Raspberry Pi supports headless setup; monitor/keyboard not needed; boot speed does not block SSH.
  3. Final Answer:

    The 'ssh' file has a .txt extension, so SSH is not enabled -> Option A
  4. Quick Check:

    File must be named exactly 'ssh' without extension [OK]
Hint: Check 'ssh' file has no extension [OK]
Common Mistakes:
  • Assuming monitor is required for SSH
  • Thinking Pi doesn't support headless mode
  • Blaming boot speed for SSH failure
5. You want to set up a Raspberry Pi headlessly to connect to a hidden Wi-Fi network named 'SecretNet' with password 'safePass123'. Which wpa_supplicant.conf snippet correctly configures this?
hard
A. network={ ssid="SecretNet" psk="safePass123" scan_ssid=1 }
B. network={ ssid=SecretNet psk=safePass123 hidden=1 }
C. network={ ssid="SecretNet" psk="safePass123" hidden=1 }
D. } 1=neddih "321ssaPefas"=ksp "teNterceS"=diss {=krowten

Solution

  1. Step 1: Understand hidden Wi-Fi config

    To connect to a hidden Wi-Fi, you must set scan_ssid=1 to actively scan/probe for the non-broadcasting SSID.
  2. Step 2: Check option correctness

    network={ ssid="SecretNet" psk="safePass123" scan_ssid=1 } includes scan_ssid=1 with correct quotes around SSID and password.
  3. Final Answer:

    network={ ssid="SecretNet" psk="safePass123" scan_ssid=1 } -> Option A
  4. Quick Check:

    Hidden Wi-Fi needs scan_ssid=1 [OK]
Hint: scan_ssid=1 for hidden Wi-Fi [OK]
Common Mistakes:
  • Omitting scan_ssid=1 for hidden networks
  • Not quoting SSID and password
  • Using wrong parameter names like 'hidden=1' alone
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard