2

I cannot currently use sudo. I also cannot edit the etc/sudoers file because sudo does not recognize me.

$ whomai
myusername

$ sudo visudo
Password:
myusername is not in the sudoers file.  This incident will be reported

$ su - root
Password:
My-MacBook-Pro-3:~ root# sudo visudo
root is not in the sudoers file.  This incident will be reported.

How can I get permission to use sudo?

steel
  • 375
  • In order to run visudo you need superuser privileges. If you have access to the root account then enter the root password, not your own and run visudo. Then you can add your user by username and grant them sudo privileges. From what I have read the root account is disabled by default on OSX. Enable it run su - root again. Be careful with the visudo file. If you are not familiar with the vi editor you won't be able to use it (assuming that vi is the editor that is used to open the sudoers file). –  Apr 21 '15 at 19:28
  • I'm fine with the vi editor, but thanks for the warning. So I enabled the root user and it still didn't work. Example updated. – steel Apr 21 '15 at 19:35

1 Answers1

4

If you have already become root you don't need to use sudo again. So in your second example, after the su root just run visudo directly

su root
visudo
Chris Davies
  • 116,213
  • 16
  • 160
  • 287