Linux is a multi-user environment by default. Each user has his own folder in /home/TheUserName
Users are highly restricted outside that folder. They only have read access to most things.
By default, the Raspberry Pi comes with a single user called pi
. This user has a home directory called /home/pi/
. The catch: By default the pi
user has the ability to access anything through sudo
, which executes commands as root.
The solution
Make a new user. By default, new users don't have sudo
access.
sudo adduser guest
Now, when logging in (assuming terminal mode):
Just enter guest
as a username, enter your password, then type startx
to get into the GUI. This user will not be able to modify anything outside /home/guest
.
You may also want to change the default "Pi" password, execute this as pi
:
sudo passwd pi
Now your guest user will only be able to destroy their own /home/guest directory without damaging the rest of your Raspberry Pi.
Extra
You may also want to backup the fresh /home/guest. So that in case a guest messes the guest user up, you can simply recover it from the backup.
execute this as pi
:
mkdir /home/pi/backup
sudo cp /home/guest /home/pi/backup/guest
To recover the guest account:
sudo rm -f -r /home/guest #Remove the guest folder.
sudo cp /home/pi/backup/guest /home/ #Copy the backup to where the guest folder used to be.
sudo chown -R guest /home/guest #Give "guest" ownership of the new guest folder.
If you want the guest account to always reset on startup, make sure that same script always executes on boot by putting it in /etc/rc.local
.
sudo
is not meant for guests. This is a good definition of an "advanced feature".