5

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.

Tobias
  • 1,678

3 Answers3

3
  • 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.
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>
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.

Tobias
  • 1,678