File Permissions and Chmod Simulator¶
Specification¶
The full specification below is extracted from Chapter 11: Booting, the Desktop, and the Linux Terminal on the Pi 500+.
Type: microsim
**sim-id:** file-permissions-chmod-simulator<br/>
**Library:** p5.js<br/>
**Status:** Specified
Learning objective: Students will *apply* (Bloom L3: Apply) a chmod permission change to a file and predict the resulting read/write/execute access for owner, group, and others.
Canvas: 700x420px, responsive — recompute the three permission-group panel widths as fractions of `width` inside `windowResized()`.
Layout: three side-by-side panels labeled "Owner," "Group," "Others," each showing three toggle switches for Read, Write, Execute, drawn as small colored squares that fill in (circuit green `#2E7D32`) when "on." Above the panels, a live-updating monospaced readout shows the resulting ten-character permission string (e.g., `-rwxr-xr-x`) that matches the current toggle states.
Controls: clicking any toggle square flips that specific permission on/off, immediately updating the readout string above; a `createButton()` labeled "Reset to 644 (rw-r--r--)" restores the common default file permissions; a second `createButton()` labeled "Set to 755 (rwxr-xr-x)" sets the common "executable script" permissions used in the chapter's `chmod +x` example.
Interaction: hovering any toggle shows a tooltip naming which category and permission it controls (e.g., "Group: Write"). Below the readout, a short auto-generated sentence explains the current state in plain language, such as "The owner can read, write, and run this file. The group and others can only read it." — regenerated every time a toggle changes.
Implementation: p5.js. Store state as a 3x3 boolean array `[owner, group, others] x [read, write, execute]`. Rebuild the permission string and the plain-language sentence from that array on every `draw()` call. Toggle hit-testing via rectangle bounds-checking in `mousePressed()`.