Home > Wiki Tips

What Is Sudo in Mac Terminal & How to Run Sudo on Mac

Updated on Monday, April 8, 2024

iBoysoft author Connie Yang

Written by

Connie Yang
Professional tech editor

Approved by

Jessica Shee

English Deutsch

Sudo in Mac Terminal: What It Is & How to Run It

Summary: This post is an overview of sudo in Mac Terminal. It elaborates what sudo in Mac Terminal is, how to enter sudo mode on Mac, and the basic sudo commands. Also, it answers the common questions about sudo. - From iBoysoft

Sudo Mac Terminal

If you need to run as the root user in Terminal on Mac to do some system-related changes or fixes that need the root privilege, you need to use the sudo command. If you are not familiar with sudo in Mac Terminal, follow this article.

Table of Contents:

enter sudo mode in Terminal

What is sudo in Mac Terminal?

Sudo is short for superuser do. It allows the permitted user (the administrator user) to run commands in the Mac Terminal as a superuser or another user with extra security privileges. For example, run the cd command in Mac Terminal to open directories (also called folders).

For security reasons, the operating system of every device separates the normal user (or we say the user who is currently logged in) from the root. When you perform tasks that require to access the hidden and deep areas of the system, you will be asked to run as the root user. But it is not safe to enable the root user on Mac. So, running the sudo command in the Terminal is the best alternative.

You can get more information about sudo in Terminal. Simply open Terminal and then type in man sudo and then hit Return. Then, you'll get a detailed explanation about sudo.

Share to tell more people what the sudo command is in Mac Terminal.

 

How do you run Terminal in sudo mode?

By default, the root user mode is disabled on Mac. And it is not advisable to enable it for security reasons. If you need to fix some issues or make some changes on Mac that require the root user privileges, you can run commands as an administrator in the Mac Terminal. In other words, that is to run Terminal in sudo mode.

To enter sudo mode in the Terminal, you need to run the fixed command with "sudo". For example, if you need to turn off your Mac, type in the shutdown command line with sudo, just as below sudo shutdown

run sudo command in Mac Terminal

Note that only the administrator of the Mac can run the sudo command in Terminal. If you are not the sharing user of the Mac, the sudo command won't work.

Don't hesitate! Share the way to enter sudo mode in Mac Terminal with your friends.

 

Mac sudo password not working, what to do?

You may prepare to run a sudo command in Mac Terminal but get the error message "Sorry, try again" after you enter the password, or you even can't type a password in the Terminal. Running the sudo command in Terminal requires you to log into your Mac with the administrator account. Or, sudo is invalid.

If you are sure that you type in the right admin password, you can try the following troubleshooting ways to fix the sudo password that's not working on Mac.

  • Quit Terminal and then relaunch it. Then, run the sudo command again.
  • Disable TextExpander. If you have installed TextExpander on Mac, check if this utility causes the Mac sudo password not to work. That's because some users report that this program can auto-capitalize the first word in a sentence, causing the first letter of the password to be capitalized when typing.
  • Change your password and use the new password to check if the sudo command works this time.
  • Restart your Mac. That can refresh the system and eliminate the tiny errors in macOS that may lead to the admin password not working for sudo.

FAQs about sudo Mac Terminal

A

Sudo password refers to the administrator password of your Mac. Every time when you run a sudo command in Terminal, it requires you enter your administrator password for confirmation.

A

Sudo offers the superuser privilege to the administrator user who running it and requires the administrator password. While, su allows the current login user (not the administrator user) have the root user privilege and asks for the current user’s password.