Deleting Accounts

To delete a user:

userdel <user name>

And delete their home directory:

userdel –r <user name>

 

Now that you know this, as a general practice, don’t delete users. (Why is this a bad idea?)

 

To find all files owned by a user (outside their home directory):

find / -user <user name> #use this formulation on a command line

find / -user <user name> -exec rm –i {} \; #use this formulation
#in a script

find / -user <user name> -exec chown <new user> {} \;

The string { } is replaced by the file name as find finds it.

In the last example, the file names will be processed until the character ; is found. At that point execution stops. The backslash \ is the escape character. The semicolon could have been protected with single quotes just as effectively.