How to enable Touch ID for sudo commands on your Mac

enable Touch ID for sudo

Using the Terminal on your Mac can be powerful and efficient, especially when you harness the capabilities of the sudo command. This command lets users perform administrative tasks, but it traditionally requires to repeatedly enter your password.

And this can get annoying very fast. But you’re using a Mac with a Touch ID, so why not enable it for sudo commands?

What is sudo?

The sudo command is very powerful and stands for “superuser do.” It allows a user with the right privileges to execute commands with administrative rights. Which can be quite dangerous.

Learn more about this command here.

What is needed to enabling Touch ID for sudo

  • Mac with Touch ID: obviously
  • macOS Version: macOS Catalina (10.15) or newer.
  • Admin Access: You must be an administrator.
  • Terminal Access: obviously

How to enable Touch ID for sudo

Step 1: Open the Terminal

Launch the Terminal by navigating to Applications > Utilities > Terminal, or by pressing Cmd + Space and typing “Terminal.”

Step 2: Edit the sudo PAM Configuration File

Type the following command to open the sudo PAM configuration file in your preferred editor:

sudo vim /etc/pam.d/sudo

Enter your password when prompted. This opens a system-level file responsible for sudo authentication.

Step 3: Add the Touch ID Authentication Line

At the very top of the file, insert the following line:

auth sufficient pam_tid.so

This line enables Touch ID as a sufficient authentication method for sudo.

Step 4: Save & Exit

This depends on the editor you’re using. For vim, use wq!

Step 5: Test Touch ID with sudo

Run a sample command. For example, you can purge RAM with :

sudo purge 

You’ll see that, instead of typing your password, your Mac will prompt for your fingerprint via Touch ID.


Troubleshooting Tips

  • Double-check that the pam_tid.so line is at the top of the file.
  • Restart Terminal or your Mac if necessary.
  • To revert, open the file again and delete the added line.