1

Disclaimer: I am NOT at all fluent in coding or its jargon, so bear with me.

I recently downloaded a software and wanted to remove it. I tried to do it via sudo on the MacBook terminal. I was trying to follow the advice from this website: http://osxdaily.com/2014/02/06/add-user-sudoers-file-mac/

Incidentally, I literally typed "username" instead of my actual username for my actual account. Now I can't even touch sudo or do anything with it.

I try to type visudo and it says "permission denied." I try to type sudoer and it doesn't give me the prompt to type the password like it did before and it doesn't respond to any input I place in, whether it is spam or a helpless help command.

I followed the advice here and it still doesn't work. Now I have two admin accounts. I am beyond lost now as to how to revert my sudo thing.

Edit: I ran the code ls -l /etc/sudoers and the results were -r--r----- 1 root wheel 2306 May 7 02:21 /etc/sudoers

Inputed cat /etc/sudoers command. Embarrassing username from middle school inbound:

enter image description here

12
  • What happens if you log in with the newly created admin account and run sudo echo Hello from there?
    – nohillside
    May 7, 2019 at 6:09
  • I entered it and nothing happens. It doesn't give any response. I keep typing enter and it just keeps entering with no text.
    – Chris Li
    May 7, 2019 at 6:13
  • The change you describe in your question shouldn't have had any negative effects at all, it just would have allowed a non-existing user to use sudo. So either something else got changed (maybe without you noticing it), or you did something else outside of visudoas well.
    – nohillside
    May 7, 2019 at 6:35
  • Can you please run ls -l /etc/sudoers and edit the result into the question? Then boot into single user mode again, run cat /etc/sudoers > /Users/Shared/s; chmod 666 /Users/Shared/s, then reboot as usual and add the content of /Users/Shared/s to the question as well?
    – nohillside
    May 7, 2019 at 6:39
  • I figured given me literally adding "username" when I should've put in my actual username has actually created a non-existing user to use the sudo command. I even made another account on my mac titled "username" to hopefully reaccess visudo, but it didn't work... My educated guess from my lack of programming experience is that I think at this point it's about working to revert this and giving it back to my actual admin account.
    – Chris Li
    May 7, 2019 at 7:32

1 Answer 1

3
  • Reboot into Single User mode
  • Run /sbin/fsck -fy
  • Run /sbin/mount -uw /
  • Run vi /etc/sudoers (assuming you know vi, otherwise use nano)
  • In the "User privilege specification" part replace %awesomechris with %admin (the % is important)
  • Save and reboot

PS: The % identicates a user group, so creating a new user didn't help (even if you would have named it awesomechris instead of username)

PPS: Once everything is fixed, remove Admin rights from users who don't need it (make sure at least one is left). Then log in with an admin user, run sudo WHATEVER-IS-NEEDED-TO-REMOVE-YOUR-SOFTWARE and enter the password of the same admin user to confirm).

2
  • 1
    I have been up since 1AM and now it's 5AM and the birds are chirping. You did it. You're truly the best I can't thank you enough.
    – Chris Li
    May 7, 2019 at 9:07
  • @ChrisLi You're welcome. When using visudo it's usually better to add new stuff instead of replacing existing entries. This significantly reduces the risk of locking oneself out.
    – nohillside
    May 7, 2019 at 9:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .