Previous Section  < Day Day Up >  Next Section

Recipe 8.7. Deleting a User

8.7.1 Problem

You need to delete a user, and you want to track down all the files that belong to the user.

8.7.2 Solution

Use userdel to delete the account, and use find to locate the files belonging to the user.

To delete a user:

# userdel aborg

The user cannot be logged in or running any processes for userdel to work.

userdel removes the user from all system account files (/etc/passwd, etc/shadow, /etc/group), but it does not touch files owned by the user. To remove the user's home directory and mail spool, add the -r flag:

# userdel -r aborg

Other files, such as crontabs and data files outside the home directory, will have to be hunted down separately:

# find / -uid 1200


The politics and policies around terminating someone's account are sensitive. If this is a home system, do whatever you want. If it's a commercial system, make sure you understand your company's policies. It's always a good idea to remove or lock the account of any employee who is terminated. Then back up the employee's files.

8.7.3 See Also

    Previous Section  < Day Day Up >  Next Section