userdel without -r option

Haruna Umar AdogaHaruna Umar Adoga Member Posts: 24 ■□□□□□□□□□
Hello everyone, I am a newbie with the linux OS and have been playing around with adding and removing users, after adding a new user, I tried deleting the user using the userdel command without the -r option, using the ls command still shows the user on my PC and if i try to delete the user again, it says such user does not exist even when i use the -r option. What should I do to get rid of the user ? any help will be appreciated


  • Options
    DoubleNNsDoubleNNs Member Posts: 2,015 ■■■■■□□□□□
    It shows the user's files when you use the ls cmd, not the user itself.

    You deleted the user but kept the files in their home directory intact. If you rm - r their home directory, you'll finish completely removing the user and their files.

    That's what happens when you use the userdel cmd. Try doing a man userdel to see what the different flags accomplish.

    userdel -f - also deletes files other users might've placed in the deleted user's home directory, even if root put it there. (safer to use userdel -r)
    userdel -r - removes the user and their home directory recursively.
    userdel - w/o any flags deletes the user but doesn't delete their home folder.
    Goals for 2018:
    Certs: RHCSA, LFCS: Ubuntu, CNCF CKA, CNCF CKAD | AWS Certified DevOps Engineer, AWS Solutions Architect Pro, AWS Certified Security Specialist, GCP Professional Cloud Architect
    Learn: Terraform, Kubernetes, Prometheus & Golang | Improve: Docker, Python Programming
    To-do | In Progress | Completed
  • Options
    XavorXavor Member Posts: 161
    You can create the user again. You will see some errors where it tries to create the mail directory, but it already exists. Then you can remove the user with the -r flag and it should clean them out.

    Or, you can do a find on / for the user and manually delete directories.
  • Options
    Haruna Umar AdogaHaruna Umar Adoga Member Posts: 24 ■□□□□□□□□□
    Thanks guys for helping out, will try the rm -r command to delete the user home directory recursively as advised..
Sign In or Register to comment.