3

I have set up Ubuntu 16.04 with PowerBroker Identity Services to login with users from an Active Directory database.

Whenever I login with a new account, the user is added to the list of users that appear when clicking the gears in the top right corner of the unity panel. The Lock/Switch Account list.

Often I need to test what happens the first time a user logs in, but what is the correct way to 'reset' a user that has been logged on to the system?

I can delete their home directories etc., PowerBroker has a cache that I clear as well, but the accounts still appear in the top right corner, so they're evidently not completely removed.

I have been looking into the FreeDesktop Accounts Service, thinking that might include some functionality to 'clean up' a user account, but I haven't found anything that seems related to that.

Things I have tried include, but are not limited to:

sudo userdel [username] 
sudo rm -rf [home]
sudo rm /var/log/btmp
sudo rm /var/log/wtmp
sudo rm -rf /var/cache/lightdm/dmrc

userdel returns:

userdel: cannot remove entry '[username]' from /etc/passwd  
/usr/sbin/deluser: `/usr/sbin/userdel [username]' returned error code 1. Exiting.

The user does not exist in /etc/passwd (they exist only in Active Directory).

[username] is the username of the user as read from $USER with \s being escaped and [home] is the path as read from $HOME.

  • Possibly of interest: askubuntu.com/a/575390/158442 – muru Jan 13 '17 at 6:20
  • I have seen that one, that is what led me to look into AccountsService in the first place. I am unable to get any further down that road. – Tobias Jan 13 '17 at 7:15
  • did you try just deleting the file mentioned there? – muru Jan 13 '17 at 7:34
  • I didn't know the file even existed, it says to create the file. I've tried deleting the file now and this appears to be the solution. Nice catch @muru . From what I can see, this achieves what I wanted. – Tobias Jan 13 '17 at 7:48
  • you can post an answer, that's fine by me – muru Jan 13 '17 at 11:16
1

use the command from terminal

sudo userdel <username>

after this you can delete the home directory of that user using

rm -r -f </home/username>
|improve this answer|||||
  • I already stated that I've tried with userdel, but perhaps I wasn't clear enough on this. Will edit for clarity. – Tobias Jan 13 '17 at 5:54
1
  • you can simply do it from GUI Mode
  • Allsettings->UserAccounts
    then unlock your Accounts panel and you can add ,del the users at very ease.
  • you will be prompted whether to delete the user files or keep them in the database.
|improve this answer|||||
0

With help from muru, I found that the correct way to remove the remaining traces of a user after deleting its home directory; is to delete the file named after the user in /var/lib/AccountsService/users/

So what I do to remove a network account that has logged in is:

sudo rm -rf [home]
sudo rm -rf /var/lib/AccountsService/users/[user]

Where [home] is the path to the user's home directory and [user] is the username.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.