Sudo not working

Joined
Jul 17, 2010
Messages
3
Reaction score
0
Points
1
Hi,
On my computer, I have a standard account and an administrator account. When type in "sudo ls" from either account in terminal, it says "sorry, try again" when I type in the administrator password and "<username> is not in the sudoers file. This incident will be reported." I know the administrator password, though, and it works fine when logging in. How do I fix it so sudo works?
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
sudo ls

should then prompt you for a pass word root does not need to be enabled. the pass word should be your administrator accounts pass word.
 
OP
M
Joined
Jul 17, 2010
Messages
3
Reaction score
0
Points
1
Still not working

This is what happens:

$ sudo ls
Password: <I enter the correct administrator password here>
Sorry, try again.
Password:
Sorry, try again.
Password:
Sorry, try again.
sudo: 3 incorrect password attempts
$

Is there some file that is corrupted?
 

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)
Are you using your password? Use the password for the currently logged in account.
 
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
Does OS X have an /etc/sudoers listing? I'm at work right now, so no OS X boxes are available. However, I often have to add users to the /etc/sudoers file in AIX.
 
Joined
May 14, 2009
Messages
2,052
Reaction score
136
Points
63
Location
Near Whitehorse, Yukon
Your Mac's Specs
2012 MBP i7 2.7 GHz 15" Matte - 16 GB RAM - 120 GB Intel SSD - 500 GB DataDoubler Mac OS 10.9
Does OS X have an /etc/sudoers listing? I'm at work right now, so no OS X boxes are available. However, I often have to add users to the /etc/sudoers file in AIX.
Yes, It does have that listing.
 
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
You /etc/sudoers file should look something like this:

# 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
 

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)
It should be like that by default. If not, you can use something like TextEdit or nano to edit it. Or, you could use visudo as it is recommended. The issue here though is that you'll need root privileges to edit it and if you can't sudo anything, we have a bit of a problem. I'm at a bit of a loss here as to how to edit/view it if you don't have the appropriate password.
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
Since this appears to be a pass word issue. Be sure the caps lock key is off.
 
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
When in doubt, log off or reboot. Meaning disable or enable root access in keychain, and then log out then in to reread the profile. It'd reboot to restart services and recycle config files.
 

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