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.
1 Answer
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
-
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!) ;-)– FabbyJan 31, 2015 at 4:29
-
-
-
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?– ImtntFeb 2, 2015 at 18:50