How can I write a small script to clean every directory's files when the computer starts?

Solution 1:

You can safely remove all files in the home directory, because they are recreated, apart from files copied on user creation from /etc/skel, so

#!/bin/bash

shopt -s dotglob 
rm -rf /home/username/*
sudo -u username cp -a /etc/skel/* /home/username/

where username should be substituted with something meaningful.

Per your request ("when computer starts") this can be executed from /etc/rc.local. More likely, you want to execute it between each to logins, so put it under /etc/gdm/PostSession or /etc/gdm/PreSession.

Solution 2:

You are describing the guest session. I'm not entirely sure how that works, but in 11.10 it is shown by default in the welcome screen. That account does exactly what you want so the question is if you want to spend time trying to recreate it on 11.04, or if you'd rather wait until you're comfortable with upgrading to 11.10. It's entering Beta 1 on Thursday. In any case, it doesn't hurt to download and boot a live session and see how you like it. If it's exactly the way you want it, then you'll know how to recreate it.