← System admin on a Raspberry Pi

System admin on a Raspberry Pi: recap

For after the lessons: one card per lesson, to check what you remember. Answer each question in your head or on paper first, then check it. Nothing here is marked.

Set up

1. Log in to the Pi from your laptop

Try firstWhere does a command run after you ssh to the Pi, and how do you get back?

Check your answer

On the Pi. Type exit to return to your laptop.

ssh pi@raspberrypi.local joins your keyboard to the Pi. After you log in, every command runs on the Pi, and only the text comes back. exit brings you back. The name raspberrypi.local is steadier than the address, which the router may change.

From the laptop, ssh pi@raspberrypi.local: the prompt changes from sam@laptop to pi@raspberrypi, because the Pi is now doing the work.
From the laptop, ssh pi@raspberrypi.local: the prompt changes from sam@laptop to pi@raspberrypi, because the Pi is now doing the work.
Open the lesson →

2. Install software with apt

Try firstWhy do you run sudo apt update before installing?

Check your answer

It downloads the list of packages; without it, a new Pi does not know what exists.

sudo apt update downloads the list of available programs. sudo apt install name installs one. sudo apt upgrade installs newer versions. sudo runs one command as the administrator, and the system records who used it. Without a network, apt cannot reach its source.

After sudo apt update and sudo apt install tree, the tree command is there and draws the folders as a tree.
After sudo apt update and sudo apt install tree, the tree command is there and draws the folders as a tree.
Open the lesson →

People

3. Accounts, groups and sudo

Try firstWhat is the difference between adduser and usermod -aG?

Check your answer

adduser makes the account and its home. usermod -aG adds an existing account to a group.

sudo adduser alex makes an account with a private home folder. Groups give several accounts the same rights: sudo usermod -aG class alex adds alex to class and keeps Alex's other groups. Only users in the sudo group may use sudo, and /var/log/auth.log records who did.

After sudo adduser alex, Alex has a home folder, /home/alex, that only Alex (and an administrator) can open: drwx------.
After sudo adduser alex, Alex has a home folder, /home/alex, that only Alex (and an administrator) can open: drwx------.
Open the lesson →

Serve

4. Services: start, stop and enable

Try firstsmbd is running but disabled. What happens after a reboot?

Check your answer

It stays off: disabled means it does not start at boot.

A service is a program the operating system keeps running. sudo systemctl start name runs it now; sudo systemctl enable name runs it at every boot. They are separate. systemctl status name shows both, and journalctl -u name shows its log.

After sudo systemctl stop smbd, systemctl status smbd says inactive (dead): the program is not running, even though it is installed.
After sudo systemctl stop smbd, systemctl status smbd says inactive (dead): the program is not running, even though it is installed.
Open the lesson →

5. Share files with Samba

Try firstWhy does smbd need a restart after you edit smb.conf?

Check your answer

It reads the file when it starts, not every time it is used.

A share is a folder offered over the network. Samba reads its shares from /etc/samba/smb.conf when it starts, so after a change you restart it: sudo systemctl restart smbd. Who may write is decided by the folder's owner, group and permissions: sudo chgrp class /srv/class and sudo chmod 775 /srv/class. Writing a root-owned file needs echo ... | sudo tee -a file.

After the share is added to smb.conf and smbd is restarted, smbclient -L localhost lists classshare.
After the share is added to smb.conf and smbd is restarted, smbclient -L localhost lists classshare.
Open the lesson →

6. Host Jellyfin, a media server

Try firstWhy might Jellyfin find no films in /home/pi/Videos?

Check your answer

It runs as the jellyfin user, and a private home folder keeps other users out.

Jellyfin is a media server: it serves your films and music over the network, on port 8096. It runs as its own user, so it can only read files that user may read, which is why films go in a shared place like /srv/media, not a private home folder. A firewall (ufw) blocks every port you do not allow: sudo ufw allow 8096.

ss -tln lists the ports with a service listening. Port 8096 is Jellyfin's web page: other devices open http://raspberrypi.local:8096.
ss -tln lists the ports with a service listening. Port 8096 is Jellyfin's web page: other devices open http://raspberrypi.local:8096.
Open the lesson →

Keep it running

7. Keep it running: backups and schedules

Try firstWhat are two reasons a backup might fail you?

Check your answer

It is on the same disk; it has never been tested.

tar -czf backup.tar.gz folder makes a compressed copy; tar -tzf lists it; tar -xzf restores it. cron runs a command on a schedule: five fields (minute, hour, day of month, month, weekday), so 30 2 * * * is 02:30 every day. Keep the backup on a different disk, and test the restore.

tar -czf makes a compressed archive of Documents on the USB drive: a copy that survives if the SD card fails.
tar -czf makes a compressed archive of Documents on the USB drive: a copy that survives if the SD card fails.
Open the lesson →

The class server

8. Challenge: the class server

Try firstName two layers of the class server and one thing each does not protect against.

Check your answer

Any two, for example: firewall (does not stop a stolen password), backup (does not stop a leak).

No single lock secures a server. Accounts and groups decide who; permissions decide what; the firewall decides which ports can be reached (allow ssh before you enable it); a backup with a schedule covers what happens when it breaks. Exposing a server to the internet raises the stakes: use a VPN instead of opening router ports.

The firewall is on with ssh allowed, so the Pi still answers. Any port not listed is blocked.
The firewall is on with ssh allowed, so the Pi still answers. Any port not listed is blocked.
Open the lesson →