Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to delete a user, but I need to keep his home dir.

I tried userdel -r user, but this also removes his home dir.

Is there a way to do this?

share|improve this question
1  
"I tried" is not enough if you try blindly and without researching. Even a quick scan of "userdel"s manual would tell you that you are asking it to remove the home directory by giving -r. –  grawity Feb 8 '12 at 9:34

2 Answers 2

The -r does the exact opposite of what you want. From userdel --help:

-r, --remove    remove home directory and mail spool

Instead of userdel -r user, just use:

userdel user
share|improve this answer

Option 1:

Use the deluser command.

However, before doing so check the file /etc/deluser.conf

And check the line

# Remove home directory and mail spool when user is removed
REMOVE_HOME = 0

Ensure this to 0 (not 1) before calling deluser.

Option 2:

sudo vipw Find the entry you want to remove (first part of the line up to the first ':' is the username). Then type "dd" to remove the entire line.

Save and exit with "esc + wq".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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