I need to delete a user, but I need to keep his home dir.
userdel -r user, but this also removes his home dir.
Is there a way to do this?
Use the deluser command.
However, before doing so check the file /etc/deluser.conf
And check the line
Ensure this to 0 (not 1) before calling deluser.
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".