I will answer your questions in turn:
1. "... why are the answers to the above commands different?"
The reason the answers of the two teams are different is because they look at two different sets of records.
The / etc / passwd file is used only by OSX in single-user mode, as indicated at the top of the file:
#
Since directory services are used for users and resources (printers, servers), you will most likely have more entries in the directory services list than the number of entries in the / etc / passwd file.
2. "... how can I delete a new user?"
To remove a user, you can use the dscl commands, as indicated by Farcaller above:
a) check the information for the user and group with:
dscacheutil -q user
And then:
dscacheutil -q group
I would also check which other users are in the same group as "newuser", which files are in / Users / newuser, and then make decisions based on this information.
b) If everything looks fine, delete the user with
sudo dscl . delete /Users/newuser
This will delete everything in the specified directory. If you want to delete the user's home directory, you will need to do this manually:
rm -rf /Users/newuser
If "newuser" was in its group, I would also look at deleting the group:
sudo dscl . delete /Groups/<<GROUP_NAME_OF_NEWUSER_FROM_A_ABOVE>>
Hope this helps.