← System admin on a Raspberry Pi

Host Jellyfin, a media server

Jellyfin serves your films and music to any device on the network, through a web page on port 8096. It runs as its own user, so it can only read files that user is allowed to read. A firewall decides which ports can be reached.

You have films on the Pi and want to watch them on the TV. What has to be true?

A media server is a service (lesson 4) that listens on a port, a numbered door on the Pi (Names and addresses in Security and privacy). Devices find the Pi by name or address, then knock on the right port. Port 22 is ssh, 445 is Samba and 8096 is Jellyfin.

How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.

Private films

Jellyfin runs as its own user, jellyfin. Your film is in /home/pi/Videos, and your home folder is private (drwx------). Can Jellyfin see it?

TryTry it on the board and compare the result with your prediction.

Try: install and look

Was your prediction right?

Try it yourselfYour edits are saved in this browser.

Install jellyfin (the lists are already up to date), then run ss -tln to see which ports have a service.

Use the board. This ticks when you get there.

InvestigateWork out why it happens, one step at a time.

Worked example: Where the films go

Worked exampleBefore each step, say what you think comes next.
  1. sudo apt install jellyfin\text{sudo apt install jellyfin}install it and start the service (on a real Pi, add Jellyfin's repository first).

Now try it yourself.

Which port does Jellyfin's web page use?

Sam's library is empty. Click the line where it first goes wrong.

Which of these plays media only on the one device it is installed on, rather than serving other devices?

ModifyChange the problem on purpose and see what happens.

Vary: change one thing

Try it yourselfYour edits are saved in this browser.

Move /home/pi/Videos/holiday.mp4 into /srv/media so that jellyfin can read it.

Use the board. This ticks when you get there.

The firewall is on and blocks everything. Let other devices reach Jellyfin on port 8096.

Use the board. This ticks when you get there.

Stop the Jellyfin service. Check with ss -tln that nothing listens on 8096.

Use the board. This ticks when you get there.

PractiseA few on your own, to check you have it.

Practise

A device opens http://raspberrypi.local:8096. What does the 8096 mean?

The firewall is on and nothing else is set. A TV tries port 8096. What happens?

Review: you edited smb.conf. What else must you do?

MakeMake your own problem using what you have learned. Expect a few tries; that is normal.

A media server

Then: on a real Pi, add Jellyfin's repository (its install page gives the commands), then open http://raspberrypi.local:8096 from another device.

Try it yourselfYour edits are saved in this browser.
Need a hint?

Before a hint: what kind of stuck is this? Try a strategy first

Three jobs: install, put the film where it can be read, open the door.

Another hint

sudo apt install jellyfin, sudo mv /home/pi/Videos/holiday.mp4 /srv/media

Another hint

sudo ufw allow 8096

Set up the media server: install Jellyfin, make holiday.mp4 readable by it, and let other devices reach port 8096.

Use the board. This ticks when you get there.

Now you can
Next lesson7. Keep it running: backups and schedulesA server that nobody looks after fails. Back up what matters with tar to a separate disk, schedule the job with cron, watch the disk space, and test the restore: a backup you have never restored is only a hope.
For teachers

Jellyfin serves your films and music to any device on the network, through a web page on port 8096. It runs as its own user, so it can only read files that user is allowed to read. A firewall decides which ports can be reached. About 40 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

Try the boards yourselves.

The one idea: a service runs as a user and gets only that user's rights; a firewall decides which ports can be reached. This links permissions (lesson 3) and ports (Networks).

Simplifications: the pretend Pi has Jellyfin in its apt list. A real Raspberry Pi OS does not: add Jellyfin's own repository first (see jellyfin.org install page), which downloads a key, and then sudo apt install jellyfin. Jellyfin also asks for a first-run setup in the browser (an admin account, a library folder). The board shows only what matters for the lesson.

Taught: Jellyfin (free, open source, no account). Other options to name: Plex (free to play your own media; some features need a Plex account or a paid Plex Pass), Emby (some features need a licence), Kodi (plays on one device, not a server). On a Pi, transcoding (changing a video's format on the fly) is slow, so use files the devices can play directly.

With internet: metadata (posters, descriptions) is fetched from the internet. Reaching your server away from home should use a VPN (Tailscale or WireGuard), not an opened router port: an open port is scanned within minutes.

Running the lesson

  1. Predict: wrong answers think a service is all-powerful.
  2. Try: ask which of the listed ports is which.
  3. Worked example: stop at the library bug and ask whose permissions apply.
  4. Vary: after the firewall task, ask what else is blocked.
  5. Make: ask what would make this unsafe to put on the internet.

The hard part (on purpose)

Seeing the service as a user. Ask: whose account runs it, and what may that account read?

When students get stuck

Stretch and support

Stretch: Find out what transcoding is and why a Pi is slow at it.

Support: A card: the user, the folder, the port.

Where it leads

Links: Networks (ports); Accounts, groups and sudo; Services; next: Keep it running.

What each step is for