Each person gets an account and a private home folder. Groups give several accounts the same rights. Only users in the sudo group may use sudo, and the system logs every time they do.
One Pi, a whole class. How does it know who is allowed to do what?
Names and addresses· Every device on the internet has an IP address, and every packet carries the address it is going to.
This is authentication (who are you?) and authorisation (what may you do?) from Who are you, and what may you do?, on a real kind of system: accounts say who, groups and permissions say what.
How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Alex's folder
TryTry it on the board and compare the result with your prediction.
Try: make an account
Was your prediction right?
Try it yourselfYour edits are saved in this browser.
Make an account for alex with sudo adduser alex. Then look at its folder with ls -ld /home/alex.
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
Worked example: Groups and sudo
Worked exampleBefore each step, say what you think comes next.
sudo adduser alexmake the account, its group and its private home folder.
sudo usermod -aG class alexadd alex to class. a = add, G = to a group. Without a, groups are replaced.
id alexlist the groups alex is in.
sudo cat /var/log/auth.logread who logged in and who used sudo (administrators only).
Now try it yourself.
Sam gives Alex sudo. Click the line where it first goes wrong.
ModifyChange the problem on purpose and see what happens.
Vary: change one thing
Try it yourselfYour edits are saved in this browser.
Alex is in the group class. Add alex to sudo as well, keeping class.
Use the board. This ticks when you get there.
Read the log that records logins and sudo use. Use sudo.
Use the board. This ticks when you get there.
Become alex with su alex. Try to read /home/pi/Documents/readme.txt. What happens?
Use the board. This ticks when you get there.
PractiseA few on your own, to check you have it.
Practise
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
A new administrator
Then: on a real Pi, run id to see your own groups.
Try it yourselfYour edits are saved in this browser.
Each person gets an account and a private home folder. Groups give several accounts the same rights. Only users in the sudo group may use sudo, and the system logs every time they do. About 40 minutes.
I can create an account and say what its home folder protects.
I can add a user to a group without removing the other groups.
I can say who may use sudo, and where the log shows it.
Before class
Try the boards yourself.
The one idea: accounts say who you are; groups and permissions say what you may do. This is authentication and authorisation (Security and privacy › Sign-in and permissions) on a real system.
Simplifications: the pretend Pi's pi account is not in the adm group, so reading /var/log/auth.log needs sudo (on a real Pi it does not). Passwords are always accepted. su alex starts a pretend session and exit returns.
On a real Pi: sudo adduser asks for a password and details; give each student their own account on the group's Pi so the log tells them apart. Never share the pi password.
Other options: useradd is the low-level version of adduser; visudo and /etc/sudoers.d/ give finer control over who may run what.
With internet: a school with many Pis would use one directory (for example LDAP or Microsoft Entra) rather than adding each account by hand.
Running the lesson
Predict: wrong answers think 'logged in' means 'allowed everywhere'.
Try: ask why a home folder is private by default.
Worked example: stop at the -a question and ask what would happen to Alex's groups.
Vary: after the log, ask what it would show if Alex had guessed passwords.
Make: ask who should and should not get sudo.
The hard part (on purpose)
-a versus no -a on usermod. Show both on the board and run id after each.
When students get stuck
A student's usermod removed their other groups. Ask: Did you use -a? Fix: Use -aG, then check with id.
Permission denied reading the log. Ask: Did you use sudo? Fix: sudo cat /var/log/auth.log.
Stretch and support
Stretch: Find out what the root account is and why Raspberry Pi OS leaves it without a password.
Support: A card: adduser makes, usermod -aG adds to a group, id shows.
Where it leads
Links: Security and privacy › Sign-in and permissions; The command line › Who can read what; next: Services.
What each step is for
Alex's folder: Committing to who can open a new home folder tests the new move: accounts keep each other out by default.
Try: make an account: Creating the account and looking at its home folder settles the prediction.
Worked example: Groups and sudo: Following the method once, then finding where a plausible account goes wrong, models the new move.
Vary: change one thing: Each task changes one thing: give a group, read the log, and see a private folder from the other side.
Practise: Choosing commands and reading groups without the board is the same move in new forms, plus a review of services.
a new administrator: Making an account and giving it the right rights is the whole move.