Sometimes a user is no longer needed to be on the system, for example, an employee leaving the company or a user that only needed temporary access to a server. In any case, you need to know how to delete users.
The last user we created was spy, right? Well, we don't need any spies on our system, so let's delete the user spy; you can delete user spy by running the command userdel spy:
root@ubuntu-linux:~# userdel spy
And just like that, user spy is deleted. However, the home directory of spy still exists:
root@ubuntu-linux:~# ls -ld /home/spy
drwxr-xr-x 2 1008 1010 4096 Apr 17 10:24 /home/spy
We would have to manually delete it:
root@ubuntu-linux:~# rm -r /home/spy
But this is inconvenient. Imagine after every user you delete, you then have to go and manually remove their home directory. Luckily, there is a better solution; you can use the -r option to automatically remove the user's home directory.
Let's give it a try with user edward:
root@ubuntu-linux...