1

I need a way to create an account that will delete itself when the system does a full poweroff, but not on a reboot or logout. It also needs to have a unique account name (not guest) and password.

Imtnt
  • 13
  • 3

1 Answers1

2
sudo adduser newuser

It will ask for password of newuser.

Create a bash script, for example: deleteuser.sh

Script:

#!/bin/sh
deluser --remove-all-files newuser

To execute a script at shutdown

  • Put your script in /etc/rc0.d
  • Make it executable (sudo chmod +x deleteuser.sh)
  • Note: The scripts in this directory are executed in alphabetical order
mertyildiran
  • 1,956
  • 2
  • 17
  • 21
  • Good one, but I would have asked an additional question: what needs to be done with the files that the user created? and then do a --delete-home or --delete-allfiles (or maybe nothing like you proposed!) ;-) – Fabby Jan 31 '15 at 04:29
  • @Fabby I updated answer. Thx! – mertyildiran Jan 31 '15 at 04:36
  • I made a correction in answer. Dİrectory should be /etc/rc0.d – mertyildiran Jan 31 '15 at 05:42
  • I actually just discovered that there are some rather stringent naming conventions for scripts in the run level folders. Specifically, they are required to start with 'K99' and not have an extension. Could you update your answer with these to save future readers a little frustration? – Imtnt Feb 02 '15 at 18:50