Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 37 ยท Projects and Practice

Practice Exercises and Project Ideas

Test what you learned with hands-on Raspberry Pi exercises: Linux, networking, services, cron, backups and data handling, each with runnable Python practice and a list of larger projects.

Reading about a Pi is not the same as owning one that works. This final lesson gives you exercises to confirm each skill from the Linux, networking, projects and deployment chapters, with runnable Python versions of the logic so you can practice even without hardware. Try each exercise before opening the solution; struggling for ten minutes teaches more than reading the answer.

The Python blocks are stand-ins for the real commands: they check your reasoning, and the real-world tasks listed under each block are for your Pi.

Exercise 1: Read a permission mode

A file shows -rwxr-x--x. Write the octal mode and say who may do what.

Python Exercise 1: octal permissions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real task: create ~/test.sh, set it to 750, and check with ls -l which of two users can run it (see users and permissions).

Exercise 2: Subnet planning

Your home network is 192.168.7.0/24. The router gives DHCP addresses .100 to .199. Choose three static addresses for a Pi, a printer and a NAS that avoid the router (.1) and the pool.

Python Exercise 2: validate static addresses

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real task: set a DHCP reservation or a static address with nmcli (network lesson) and confirm it survives a reboot.

Exercise 3: Cron schedules

Write cron expressions for these jobs, then check them in your head against the table below.

Job Expression
Every 15 minutes */15 * * * *
02:30 every night 30 2 * * *
09:00 on the first of each month 0 9 1 * *
Every Sunday at 23:00 0 23 * * 0

Now verify two of them by counting how many times each fires in a day:

Python Exercise 3: count scheduled runs

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real task: add a cron job that appends the date to a file every minute, check it for five minutes, then remove it (cron lesson).

Exercise 4: Parse a log

A service wrote these lines. Count errors per hour and find the worst hour.

Python Exercise 4: errors per hour

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real task: run journalctl -p err -b on your Pi and write the same counter for it (logging lesson).

Exercise 5: A safe web handler

Write a function that accepts /set?led=2&state=on, where only LEDs 1 to 3 exist. Return a status code and message for each request.

Python Exercise 5: validate input

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real task: build it with Flask or http.server and test with curl "http://pi.local:5000/set?led=2&state=on" (web server lesson).

Exercise 6: Backup retention

You keep daily backups. Decide by hand which of the last 10 you keep with "keep the last 3 and every 5th day." Then confirm:

Python Exercise 6: choose what to keep

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real task: write the backup script with rsync, run it twice and prove with diff -r that the copy matches (backups lesson).

Bigger project ideas

Pick one and design it on paper first: sensors, data flow, failure cases, and how you will recover.

  1. Greenhouse controller: temperature, humidity and soil sensors; fan and pump relays; dashboard; alerts (plant monitor).
  2. Home hub: Mosquitto broker, MQTT sensors around the house, a logger and a dashboard (MQTT lesson).
  3. Network appliance: DNS ad blocker and a backup target (NAS) on one Pi with an SSD (ad blocker).
  4. Door and window alarm: reed switches, PIR, buzzer, phone alerts and a battery backup (motion alarm).
  5. Weather station network: several outdoor Pis sending to one central database (weather station).
  6. Kiosk or information screen: a Pi in Chromium kiosk mode showing your dashboard, rebooting on a watchdog.

For any project, answer these before you start: What happens on a power cut? What if the network is down? Who can reach it? How will I find out it stopped? Those four questions are the course in miniature.

Final checklist

  • Starts by itself at boot (systemd).
  • Runs as a non-root user with only the groups it needs.
  • Logs are bounded and readable.
  • Data is backed up and the restore was tested.
  • SSH uses keys, the firewall is on and updates are automatic.
  • You know your Pi's IP or name and have a spare, written SD card.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the octal mode of rwxr-x--x equal?

    rwx = 7, r-x = 5, --x = 1.
  2. 2. Which cron expression runs at 02:30 every night?

    The order is minute, hour, day of month, month, day of week, so minute 30 and hour 2.
  3. 3. Why must a web handler validate the led parameter?

    Input from the network is untrusted and must be checked before it controls hardware.
  4. 4. Which question belongs on every project's design checklist?

    Failure behavior decides whether an unattended Pi is reliable.

Summary

  • Practice each skill on a real Pi after checking the logic with a small program.
  • Permissions, subnets, cron, logs, validation and retention are the recurring building blocks.
  • Design projects on paper, listing failure cases first.
  • Use the final checklist before leaving a Pi unattended.
  • Keep learning by building: every project in this chapter can be extended.

Next: Back to the Raspberry Pi course