MacOS – cannot run sudo


I have a corporate account work on my macbook that has administrator privileges and created a non-administrative account local.

Logged in as local, when I tried a command with sudo, I got the familiar is not in the sudoers file.

The file /etc/sudoers is owned by the usual root/wheel. I tried to modify the file inside a su work shell but it was readonly for that user. Then I tried su root but that didn't work either. Then I found out that I need to enable to the root user.

I enabled the root user, but still cannot su root, still get the same terse su: Sorry. I seem to have enabled the root user correctly, since the process to enable it now gives the option to disable it or change password.

How can I get su to work for user local? Is there a another way to allow the user local to use sudo?

Best Answer

I found out that the I was able to modify /etc/sudoers when I logged in as work using ssh. Not sure if I had made some mistake with my previous attempt with su - work.

The following steps worked:

  • Logged in as local, start with ssh work@localhost
  • sudo visudo
  • Add entry local ALL=(ALL) ALL
  • Save and exist vi
  • Exist ssh session
  • Try sudo ls /