Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My sudo command not working [closed]

I have a mac 10.8.2 mountain lion and when i try to use the sudo command i get this:

 sudo: /private/etc/sudoers is owned by uid 501, should be 0
 sudo: no valid sudoers sources found, quitting

I have searched google all over and tried a couple of things but one thing kinda fixed my orignal perm problem with 0440 being 0640 or something but i got this. Any help will be appreciated

like image 206
user1794522 Avatar asked Nov 02 '12 14:11

user1794522


People also ask

Why sudo command is not working?

How to Fix "sudo: command not found" on Linux. As your user cannot assume the privileges of the root user without already having sudo installed, you need to log out of your user account and log in as root. As root, you can install the sudo package with the privileges this account possesses.

How do I fix sudo?

The result can be an impaired instance that can't run sudo su or commands that require privileged user access. To fix this syntax error, stop the instance, detach its root volume, attach it to a recovery instance, mount the root volume as a secondary volume, and then revert the changes to the sudoers file.

How do I exit sudo?

When you type exit as root, sudo will terminate. Since the exec replaced the user's shell process with sudo , then there's no user shell to which to return.


1 Answers

The easiest way to fix this is with Disk Utility's Repair Disk Permissions feature. Run Disk Utility, select your startup volume in the sidebar, select the First Sid tab, and click Repair Disk Permissions.

And in the future, use the visudo command to edit the sudoers file to avoid this sort of problem.

Update: the Repair Disk Permissions feature was removed in El Capitain (10.11), because it's (mostly) replaced by System Integrity Protection. If you need to fix the permissions on /etc/sudoers in 10.11 or later, you can do it from AppleScript:

  1. Open the Script Editor utility.
  2. If a new (blank) script window doesn't open automatically, choose File menu > New (or press Command-N) to open one.
  3. Enter the following script:

    do shell script "chown root:wheel /etc/sudoers; chmod 440 /etc/sudoers; chmod -N /etc/sudoers" with administrator privileges
    
  4. Choose Script menu > Compile (or press Command-K, or click the Compile button in the toolbar). It should colorize the script to indicate the AppleScript syntax. If it reports any errors, make sure you copied the script correctly.

  5. Choose Script menu > Run (or press Command-R, or click the Run button in the toolbar).
  6. Enter your admin password when prompted.
like image 123
Gordon Davisson Avatar answered Nov 04 '22 18:11

Gordon Davisson