How would one make a true shell in a website like this one? (As in, is there an open source library to host an interactive shell for educational purposes - eg codecademy)

I couldn't tell you the exact details (I'm only passingly familiar with how it works myself), but you'd almost certainly want to start by looking into web assembly.

I found a-Shell's documentation[1] quite interesting, it describes their use of web assembly and offers some practical tips for compiling stuff so it can work in a sandboxed environment.

[1]: https://bianshen00009.gitbook.io/a-guide-to-a-shell/lets-do-...