How can you prevent users from leaving a directory?
chroot, and override exit with an alias,could work
How can you prevent a shutdown using a power key?
You can’t, lol. Think it’s just a joke

There’s an Emacs command to do that

C-x M-c M-minefield

Encrypt hard drive and keep the key in RAM. Could be recovered with a cold boot attack but that’s very advanced. The DOS virus ONEHALF would run as a daemon encrypring a block on the drive on each boot and intercept reads/writes to the encrypted part as if nothing ever happened. Only after encrypting ½ of the disk, it would reveal itself with an ominous

Dis is one half. Press any key to continue...

The decryption was eventually cracked by ESET and they developed a tool to recover the drive.

If you are using KDE

AFAIK, there’s no way to without modifying the system tools and shell.
Magic, I guess, 'cause nothing in the sceenshot would do it, unless the attacker had already replaced cat with a trojan or something.