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

nohillside
  • 100,768
  • What happens if you log in with the newly created admin account and run sudo echo Hello from there? – nohillside May 07 '19 at 06: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 07 '19 at 06: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 07 '19 at 06: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 07 '19 at 06: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 07 '19 at 07:32
  • Ah, sorry, my bad. You need to run /sbin/fsck -fy and /sbin/mount -uw / first after booting to Single User Mode, afterwards the cat part will work. – nohillside May 07 '19 at 07:49
  • Good thinking about the username account, this should have worked. So I still think something else is interfering here as well. – nohillside May 07 '19 at 07:50
  • Is there any way to see what username I typed in for the %admin ALL=(ALL) ALL sudo admin part? – Chris Li May 07 '19 at 08:06
  • Well, if you replaced the %admin ALL=(ALL) ALL (instead of adding an additonal one) this might explain what you are seeing. To see the content please do as indicated above (single user, run fsck and mount, cat file, reboot, add file to question) – nohillside May 07 '19 at 08:14
  • But to make it easier: Just run cat /etc/sudoers after booting to single user, and post the picture. I think we can fix it directly there. – nohillside May 07 '19 at 08:35
  • Alright, updated. However, my username stated above already corresponds to an existing user account that's just standard and doesn't have and administrative powers. I actually just updated all my accounts now to have administrative powers and no sudo commands work still. – Chris Li May 07 '19 at 08:53
  • See my answer below – nohillside May 07 '19 at 08:56

1 Answers1

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).

nohillside
  • 100,768
  • 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 07 '19 at 09: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 07 '19 at 09:09