userdel
remove a useruserdel removes an account from the system. Without -r the home directory is left behind, owned by a number that no longer has a name — and that a future account may be given.
Decide what happens to the files first: archive them, then userdel -r.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
The account has a process running, so userdel refuses rather than leave it orphaned.
pkill -u ends everything the user is running.
-r deletes /home/olduser and the mail spool along with the account. Nothing is printed on success.
-nouser finds files whose owner id no longer matches any account. This one, outside the home directory, was missed by -r.
Switches
A switch changes how the command behaves. These are the ones used day to day; man userdel lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-r- Remove the home directory and mail spool too.
-f- Force removal even if the user is logged in. Dangerous.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
sudo tar -czf olduser-home.tar.gz /home/olduserArchives the home directory before deleting the account.
sudo userdel -r olduserDeletes the account with its home directory.
sudo find / -xdev -uid 1003Finds every file owned by a given user id.
sudo deluser --remove-home olduserThe Debian and Ubuntu wrapper for the same job.
In cybersecurity
Removing an account is part of the job when someone leaves — and easy to do halfway.
Files left behind are owned by a bare number. The next account created may be given that number and inherit them all.
Cron jobs, SSH keys in other accounts’ authorized_keys, and running processes outlive the account unless they are removed too.
Locking an account at once and deleting it after a retention period keeps the evidence and the files while removing the access.