2

I am learning CentOS and I created some users and then deleted, but I used userdel without any option.

So will it remove the home directory and other things related to those users? If not then is there any option to remove the remaining contents of those users?

1 Answer 1

3

The manual page for userdel describes the -r option, which would remove the home-directory at the time you removed the user. If you did not do it then, you could find files with no known user with the find option -nouser, e.g.,

find /home -nouser -delete 

though you might want to verify the list before actually deleting the files:

find /home -nouser -ls 

The -delete option removes files. Removing directories would require a different command, e.g.,

find /home -type d -nouser -exec rmdir {} \; 

(although some pathological user may have created a directory with embedded blanks, requiring more work).

By the way, /home is a convention, and you may have created your user's home-directories in other places.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.