It should also be possible to control this type of activity from /etc/profile
which is read before the /home/user/.profile
and is owned by root. (See: http://bash.cyberciti.biz/guide/Startup_scripts).
However, this would not prevent the issue of opening up another xterm or a second user logging in at the same time. If the system is not multi-user, i.e. there is only one user active at a time, then you should be able to get the desired effects of clearing the home directory by using .bash_logout
. (see: Create a logoff script/task for Linux)
To ensure that users don't edit these files make sure that they do not have access to chown
and chmod
. If they do not have access to these commands and the file has some restrictive permissions set say 0440
and is owned by a different user, then the files should be secure enough to prevent tampering.