This question already has an answer here:

My machine has only one user. My goal was to change the login name, I've gone to system preferences / Users, opened my user and edited my login name to the new one and rebooted. Now I can login, but I do not have admin privileges, as I cannot run any command with sudo, as well as when I try to go to system preferences / users I cannot undo the lock as it asks for an admin username and password and it does not let me in with neither the old nor the new login.

One thing to note is that when I login my home directory is still /Users/OldUsername and ls /Users does not show a directory for the new user name.

Has anyone come across this before? Any chance this can be resolved without having to reset the OS?

marked as duplicate by grg Jun 28 '18 at 22:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.