I want to set up a Linux machine such that when a particular user, named student, logs out, their /home directory is wiped clean and reset.
Basically I want to perform these actions when the user logs out:
userdel student rm -r /home/student useradd -m student echo student | passwd --stdin student
Is there a simpler way than deleting and recreating the user?
Note: The goal here is to wipe the contents of the user's home directory and repopulate the user's home directory from /etc/skel. I guess I'm just trying to work around file ownership problems that arise when copy /etc/skel over /home/student.
Edit: What I need to do is mimic the way that
useradd -m copies the stuff from
/home/student and changes the owner, group, and permissions. How can I do what
useradd -m does without having to delete and then recreate the user?