318
votes
Accepted
Can Touch ID on Mac authenticate sudo in Terminal?
To allow TouchID on your Mac to authenticate you for sudo access instead of a password you need to do the following.
Open Terminal
Switch to the root user with sudo su -
Edit the /etc/pam.d/sudo ...
98
votes
Enable sudo without a password on MacOS
Open a terminal, run sudo visudo
Edit the line:
%admin ALL=(ALL) ALL
To say:
%admin ALL=(ALL) NOPASSWD: ALL
Now, you should now be able to run sudo without password.
80
votes
Can Touch ID on Mac authenticate sudo in Terminal?
If you're using iTerm2 (v3.2.8+) you may have seen Touch ID failing to work with sudo in the terminal despite having made the pam_tid.so modification as above, and it working in previous versions. ...
29
votes
Accepted
Can't write to /usr/lib
It is a new feature of OS X 10.11 (El Capitan): SIP.
System Integrity Protection (SIP,1 sometimes referred to as rootless2) is a security feature of OS X El Capitan, the operating system by Apple ...
28
votes
Terminal becomes unresponsive when a “sudo” password prompt is displayed
The terminal doesn't show the characters being entered when typing in a password field such as a sudo password field. The characters are still being entered—just type your password as normal and press ...
grg♦
- 195k
28
votes
Accepted
OS X Catalina: add user to sudoers
It turns out that even an admin user needs to use sudo to edit the sudoers file at /private/etc/sudoers so the following did the trick to open the file for edit:
$ sudo visudo /private/etc/sudoers
...
26
votes
Can Touch ID on Mac authenticate sudo in Terminal?
TouchID does support elevating privileges, but as of now, it only seems to be supported in Apple's own apps. My guess is that 3rd party apps will have to be updated to support it, unfortunately. I ...
22
votes
Accepted
sudo vs su (as non-root user)
This is expected behaviour.
The purpose of su is to switch user. It's called the substitute user identity tool. su takes the other user's password since you are switching to that user.
The su ...
grg♦
- 195k
19
votes
osascript is not allowed assistive access. (-1728)
If you run AppleScript code via osascript in Terminal, then you need to add Terminal to System Preferences > Security & Privacy > Privacy > Accessibility, to allow it assistive access.
I took ...
18
votes
sudo: /etc/sudoers is owned by uid 501, should be 0
You can fix this via AppleScript, without needing to reboot, or even log out & back in, or an existing root shell, or... All you need is a valid administrator password.
Run this command:
osascript ...
18
votes
Enable sudo without a password on MacOS
Better not to edit /etc/sudoers directly.
Instead, the /etc/sudoers file does include a line:
## Read drop-in files from /private/etc/sudoers.d
## (the '#' here does not indicate a comment)
#...
18
votes
Can Touch ID on Mac authenticate sudo in Terminal?
I have created a simple script that enables sudo to use the TouchID PAM module exactly as conorgriffin explains. It does it in a single script that you can copy-paste to a terminal in it's entirety or ...
18
votes
Accepted
sudo: command not found
Your PATH is hosed!
First check your .bash_profile file with:
/usr/bin/nano ~/.bash_profile
Prepend lines containing something like export PATH="/... " with a # to comment them out. Save the file ...
17
votes
Accepted
Running mc (midnight commander) under su on Mojave/Catalina/Big Sur/Monterey
It appears that mc requires to match precompiled shell version, e.g. /bin/bash to be the one.
In order to resolve this, its is required to change default root shell from sh to bash, and do it with ...
17
votes
Accepted
How do I uninstall Trend Micro Security Agent?
I just did this myself, here's what I learned while doing it.
A lot of the difficulty in uninstalling Trend Micro comes from the fact that it spawns processes that then interfere with removing it (...
15
votes
Can't write to /usr even with sudo
You are trying to install in /usr which is protected by SIP (System Integrity Protection), a feature introduced with 10.11 (see
What is the "rootless" feature in El Capitan, really? for ...
15
votes
How do I install sudo insults on Mac?
To install a sudo with insults you have to compile it yourself:
Requirements: Xcode 8.0, Sierra 10.12, probably SIP disabled
Backup sudo and visudo:
sudo cp /usr/bin/sudo /usr/bin/sudo.backup
sudo ...
14
votes
Accepted
How to prevent 'sudo rm -rf /'
You can add a line like
%admin ALL = !/bin/rm -rf /
to your sudoers file to prevent the execution of the command with the specific options.
Or, if you want to exclude several commands, you can work ...
14
votes
Accepted
How to solve "User is not in sudoers file, incident reported"
sudo exclusively uses account names, not the user's full name. As a hint, account names don't contain spaces, so "Syammala Naidu" is not correct.
To find out a user's account name:
Open ...
14
votes
Accepted
Mac OS/X won't let me mkdir /usr/share/tomcat6, even as root
That's because the /usr folder, with the exception of /usr/local, is protected by System Integrity Protection (SIP).
Check this Apple support page for more details on SIP. This answer gives details ...
14
votes
Fixing /etc/sudoers file
If you have access to finder and a system administrator account, you can fix this without a reboot by leveraging these.
Open up your finder and go to /etc. In here, you can view the details of the ...
12
votes
How do I install a .dmg file without being a sudo user?
.dmg is not an app, it is a disk image. If you double-click the file, it should mount a virtual disk in the Finder. From there, you will be able to drag and drop the image into your applications ...
11
votes
How to remove default Git or update it?
sudo rm -rf /usr/bin/git wont work for El Capitan due to SIP restriction
simple solution is create alias
alias git='/usr/local/bin/git'
11
votes
Can Touch ID on Mac authenticate sudo in Terminal?
You can use fingerprint for getting sudo access in the terminal or iTerm, just add auth sufficient pam_tid.so to the first line to your /etc/pam.d/sudo file.
11
votes
Accepted
Where are sudo insults stored on macOS?
If you run sudo strings /usr/bin/sudo you get (among a lot of other things)
Sudo version %s
1.8.17p1
Configure options: %s
--with-password-timeout=0 --disable-setreuid --with-env-editor --with-pam
--...
11
votes
Accepted
Why is sudo taking way too long?
ErikMH's answer gave me the idea to first just try to revert the sudoers file, without reverting/upgrading my whole system again. So in short:
Run this to get a root shell: sudo -s
Make a copy of /...
11
votes
Where can I find logs for failed sudo attempts on macOS Sierra?
The sudo logs now go to the new unified logging system in macOS 10.12, which can be searched using the log command.
For example, to show all sudo logs from the last 3 hours:
log show --style syslog -...
10
votes
Accepted
Kill process as root: Operation not permitted
As far as I know this is not due to SIP as such, but rather to the fact that SentinelOne includes guards against this in particular. It works by adding a kernel extension to the system, which means it ...
9
votes
Accepted
sudo: /var/db/sudo/ts is owned by uid 501, should be 0
UID 501 is the first administrator user on the machine, usually the first user that you create ergo you. Somehow ownership of the folder was set to you instead of root.
Open the terminal and change ...
8
votes
sudo: /etc/sudoers is owned by uid 501, should be 0
For macOS Mojave, here is what worked for me:
Start up in recovery mode (Cmd+R during boot up)
Disk Utilities > Select Macintosh HD, and Mount
Close Disk Utilities
Utilities > Terminal
Type: chown ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sudo × 267macos × 130
terminal × 103
permission × 38
command-line × 29
password × 25
administrator × 22
root × 17
bash × 15
mac × 10
security × 10
catalina × 9
homebrew × 9
user-account × 9
mojave × 8
unix × 8
high-sierra × 7
applescript × 6
touch-id × 6
network × 5
hard-drive × 5
install × 5
macbook-pro × 4
finder × 4
script × 4