Lost my suders file Mountain Lion

Joined
Jun 27, 2011
Messages
15
Reaction score
0
Points
1
Location
Riverside CA
Your Mac's Specs
I've had an iMac for over a year and got an Air when the new ones came out several months ago.
I attempted to edit my sudoers file using visudo. I've done this before in LINUX but I now know it is different in OX-X. I saved the file but there were errors, it's gone, and it won't recreate for for visudo. :Grimmace:

What do I do now? (other than cry)
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
Revert to a backup from Time Machine?

OR, here's a sample:

Permissions:

-r--r----- 1 root wheel 1275 Jul 28 10:05 sudoers

# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification
Defaults env_reset
Defaults env_keep += "BLOCKSIZE"
Defaults env_keep += "COLORFGBG COLORTERM"
Defaults env_keep += "__CF_USER_TEXT_ENCODING"
Defaults env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"
Defaults env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"
Defaults env_keep += "LINES COLUMNS"
Defaults env_keep += "LSCOLORS"
Defaults env_keep += "SSH_AUTH_SOCK"
Defaults env_keep += "TZ"
Defaults env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"
Defaults env_keep += "EDITOR VISUAL"
Defaults env_keep += "HOME MAIL"

# Runas alias specification

# User privilege specification
root ALL=(ALL) ALL
%admin ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
 
OP
S
Joined
Jun 27, 2011
Messages
15
Reaction score
0
Points
1
Location
Riverside CA
Your Mac's Specs
I've had an iMac for over a year and got an Air when the new ones came out several months ago.
Thanks for the file, I thought of that but I cant create a file in /etc without invoking sudo, alas. I guess it's a visit to the Genius Bar since it's a Mac Air with and no system DVD.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Create it elsewhere, open up Finder, push Shift-Command-G, enter /etc, paste. Nice and simple.
 
OP
S
Joined
Jun 27, 2011
Messages
15
Reaction score
0
Points
1
Location
Riverside CA
Your Mac's Specs
I've had an iMac for over a year and got an Air when the new ones came out several months ago.
Both the owner and the permissions are wrong and I cannot change them.
I sent a copy of the file to me from another mac and the problems persist. I can't use sudo chown ... because the sudoers file doesn't have the right permissions neither can I use sudo chmod ... for the same reason. I almost wich I had created a root user, but that's bad secuirity.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Enable the root user then and use that to recreate the sudoers file (more info here).
 
OP
S
Joined
Jun 27, 2011
Messages
15
Reaction score
0
Points
1
Location
Riverside CA
Your Mac's Specs
I've had an iMac for over a year and got an Air when the new ones came out several months ago.
Many thanks, I (obviously) didn't know one could do that or how to enable the root account. I''ll disable root now. All is right with the world (except in my office for my official "enterprise" desktop).

Now to read about sudoers before I attempt to edit it again.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top