How to Open Applications With Root Privileges on a Mac

How to Open Applications With Root Privileges on a Mac Техника

Content

Home
>
Wiki Tips

Updated on Wednesday, May 31, 2023

iBoysoft author Amanda Wong

Professional tech editor

  • Кавычки вокруг пути к файлу необходимы только в том случае, если путь к файлу содержит пробелы.
  • A mistake in root access could wipe your computer or make it unusable. The risk is higher in 10.10 or earlier, or in 10.11 with SIP disabled. Keep your administrator password private to prevent others from gaining root access.

Home
>
Wiki Tips

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

Updated on Sunday, June 25, 2023

iBoysoft author Connie Yang

Professional tech editor

English
Deutsch

 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

Table of Contents:

enter sudo mode in Terminal

  • Ошибка, допущенная во время работы с привилегиями суперпользователя, может уничтожить систему или сделать компьютер непригодным для использования. Риск выше в версии 10.10 и более ранних, а также в 10.11, когда выключена функция защиты целостности системы. Надежно храните пароль администратора, чтобы злоумышленники не смогли получить права суперпользователя.

nwinkler's user avatar

21 gold badges153 silver badges168 bronze badges

asked Jul 29, 2015 at 12:43

jmoneilthe2's user avatar

$ sudo some command here

answered Jul 29, 2015 at 12:47

deceze's user avatar

85 gold badges741 silver badges886 bronze badges

answered Jul 29, 2015 at 21:15

Aditya Kadakia's user avatar

search for terminal
after opening the termincal type

su <admin-user-name>   //su - switch user
sudo open MySQLWorkbench.app

answered Mar 28, 2019 at 18:58

Bhaskara Arani's user avatar

Bhaskara Arani

1 gold badge26 silver badges44 bronze badges

sudo <command>

You can also switch to root and every command will be run as root

sudo su

answered Sep 22, 2019 at 15:41

94230's user avatar

2 silver badges12 bronze badges

Add sudo to your command line, like:

$ sudo firebase init

answered Mar 3, 2017 at 6:50

Pedro Henrique Arthur's user avatar

sudo dscl . -create /Users/joeadmin
sudo dscl . -create /Users/joeadmin UserShell /bin/bash
sudo dscl . -create /Users/joeadmin RealName "Joe Admin" 
sudo dscl . -create /Users/joeadmin UniqueID "510"
sudo dscl . -create /Users/joeadmin PrimaryGroupID 20
sudo dscl . -create /Users/joeadmin NFSHomeDirectory /Users/joeadmin
sudo dscl . -passwd /Users/joeadmin password 
sudo dscl . -append /Groups/admin GroupMembership joeadmin

press enter after every sentence

Then do a:

sudo reboot

Stephen Rauch's user avatar

31 gold badges106 silver badges135 bronze badges

answered Dec 13, 2017 at 2:46

user9091797's user avatar

MGCXXXXXXXXD6N:~ username$ su <admin_user> 
Password: ******
bash-3.2$ _________Give your command here. It works_________________

answered Oct 14, 2021 at 12:36

Jeberdson Abraham's user avatar

Любую программу в Mac OS X можно открыть с привилегиями (правами) суперпользователя, если вы знаете пароль администратора. Но не делайте этого, если являетесь неопытным пользователем, потому что ваши действия могут нанести вред программе или системе.

  1. Изображение с названием Open Applications With Root Privileges on a Mac Step 2

    Откройте терминал. Войдите в учетную запись администратора на компьютере. Нажмите > > .

  2. Изображение с названием Open Applications With Root Privileges on a Mac Step 3

    • Введите sudo «\путь к файлу программы на жестком диске.app/Contents/MacOS/название программы«.
      Например, чтобы открыть iTunes, введите «/Applications/iTunes.app/Contents/MacOS/iTunes»}} и нажмите .
    • Введите пароль к учетной записи администратора, в которую вы вошли. Нажмите .
    • Если команда работает, программа откроется с правами суперпользователя. Если в терминале появилось сообщение «command not found» (команда не найдена), перейдите к следующему шагу.
  3. Изображение с названием Open Applications With Root Privileges on a Mac Step 4

    Откройте содержимое программного пакета. Если быстрый метод не привел к успеху, найдите программу в Finder. Щелкните правой кнопкой мыши (или зажмите и щелкните левой кнопкой) по значку программы и в меню выберите Показать содержимое пакета.

  4. Изображение с названием Open Applications With Root Privileges on a Mac Step 5

    Найдите исполняемый файл. На экране отобразится одна или несколько папок. Исполняемый файл находится в одной из них, как правило, в папке /Contents/MacOS.

    • Зачастую исполняемый файл носит то же имя, что и программа, но может называться по-другому, например, «run.sh.»
    • В большинстве случаев значок исполняемого файла выглядит как черный квадрат со словом «exec».
  5. Изображение с названием Open Applications With Root Privileges on a Mac Step 6

    Введите команду «sudo» в терминале. Введите , а затем поставьте пробел. Пока не вводите команду.

  6. Изображение с названием Open Applications With Root Privileges on a Mac Step 7

    Перетащите исполняемый файл в терминал. Путь к файлу будет автоматически вставлен в терминал.

  7. Изображение с названием Open Applications With Root Privileges on a Mac Step 8

    Введите пароль, чтобы подтвердить запуск команды. Нажмите . Введите пароль к учетной записи администратора, в которую вы вошли, а затем еще раз нажмите . Программа откроется с правами суперпользователя.

  1. Изображение с названием Open Applications With Root Privileges on a Mac Step 9

  2. Изображение с названием Open Applications With Root Privileges on a Mac Step 10

    Временно станьте администратором. В терминале введите команду , поставьте пробел, а затем введите административное имя пользователя и пароль. Так вы станете администратором на временной основе.

  3. Изображение с названием Open Applications With Root Privileges on a Mac Step 11

    Откройте программу с помощью команды «sudo». Введите команду sudo «\путь к файлу программы на жестком диске.app/Contents/MacOS/имя программы«. Если это не привело к успеху или вам нужны дополнительные инструкции, читайте первый раздел этой статьи.

  4. Изображение с названием Open Applications With Root Privileges on a Mac Step 12

    Вернитесь в гостевую учетную запись. Когда вы завершите все задачи, которым требуются права суперпользователя, в терминале введите . Так вы выйдете из административной учетной записи и вернетесь в гостевую учетную запись.

  1. Изображение с названием Open Applications With Root Privileges on a Mac Step 13

    • Перезагрузите компьютер. Зажмите + , когда услышите звук загрузки компьютера, чтобы войти в режим восстановления.
    • В меню сверху выберите > .
    • Введите csrutil disable; reboot в терминале.
    • Пусть компьютер перезагрузится как обычно. Теперь воспользуйтесь вышеописанными методами, чтобы открыть программу с привилегиями суперпользователя. Когда закончите, повторите описанный процесс, но вместо введите , чтобы снова активировать функцию защиты целостности системы.
  2. Изображение с названием Open Applications With Root Privileges on a Mac Step 14

    Используйте текстовый редактор «nano» вместо текстового редактора с графическим интерфейсом пользователя. Безопаснее и надежнее редактировать системные файлы с помощью текстового редактора в терминале. Nano — это простейший текстовый редактор, который предустанавливается в Mac OS X. Чтобы открыть этот редактор с привилегиями суперпользователя, введите , поставьте пробел, а затем введите путь к текстовому документу. Теперь документ можно отредактировать из-под терминала. Когда закончите, нажмите + , чтобы сохранить внесенные изменения, а затем нажмите + , чтобы закрыть «nano».

    • Например, команда sudo nano /etc/hosts откроет файл «hosts» с правами суперпользователя.
    • Рекомендуем сначала создать резервную копию системных файлов, а потом приступить к их редактированию. Для этого введите sudo cp путь_к_системному_файлу путь_к_файлу_резервной_копии. Например, команда sudo cp /etc/hosts /etc/hosts.backup создаст копию файла «hosts» под именем «hosts.backup». Если вы допустили ошибку, переименуйте неправильный файл в sudo mv /etc/hosts /etc/hosts.bad, а затем восстановите резервную копию с помощью sudo cp /etc/hosts.backup /etc/hosts.[8]

How to Disable the Root User

To help protect your Mac from malicious activities, or even accidental damage, disable root as soon as it’s no longer required.

How to Disable the Root User Using Terminal

  1. Launch Terminal via Finder (“Applications -> Utilities”) or Spotlight.
  2. Enter the dsenableroot -d command and press Enter.
Enable Root User Mac Disable Terminal
  1. Enter the password for your current account. You should see a prompt letting you know that the root user has been disabled.

How to Disable the Root User Using Directory Utility

  1. Launch Directory Utility.
  2. Click on the lock icon in the bottom-left corner of the window and enter your user password or use Touch ID for authentication.
  3. Click on “Edit” in the menu bar, then select “Disable Root User.”
Enable Root User Mac Disable Directory Utility

Note: you don’t need the root account for most fixes. You can even fix a frozen Mac without root access.

How to disable the root user on Mac?

  1. Log out of the root user account and log in to your administrator account.
  2. Navigate to the Apple menu > System Preferences > Users & Groups.
  3. Unlock the lock with the administrator’s name and password.
  4. Choose Login Options, then click on Join > Open Directory Utility.
  5. Unlock the lock again, then choose Edit > Disable Root User from the menu bar.

disable root user on Mac

An Explanation of Root User on Mac

root user mac

Table of Contents:

How to log in as a root user on Mac?

To turn off FileVault:

  1. Click the Apple menu, and navigate to System Preference > Security & Privacy.
  2. Select the FileVault tab.
  3. Click the lock at the left bottom and enter your password when asked.
  4. Click Turn Off FileVault.

To disable automatic login:

  1. Head to the Apple menu > System Preferences > Users & Groups.
  2. Click the lock and enter your admin name and password.
  3. Tap the Login Options.
  4. Then set the Automatic Login to Off.
  1. Choose the Apple menu > Log Out [name of current user account], then click Log Out on the pop-up window.
  2. At the login window, log in with the user name ”root” and the password you created for the root user.

FAQs about sudo Mac Terminal

iBoysoft author Connie Yang

Professional tech editor

Jessica Shee is a senior tech editor at iBoysoft. Throughout her 3 years of experience, Jessica has written many informative and instructional articles in data recovery, data security, and disk management to help a lot of readers secure their important documents and take the best advantage of their devices.

About This Article

Thanks to all authors for creating a page that has been read 716,789 times.

What is a root user on Mac?

  1. Choose the Apple menu > System Preferences, then click Users & Groups.
  2. Click on the padlock icon, enter an administrator name and password, then click Unlock.
  3. Click Login Options on the lower area of the left column.
  4. Click on the Join button next to Network Account Server.
  5. Tap Open Directory Utility.
  6. Click the padlock icon in the Directory Utility window, enter your administrator name and password, then choose Modify Configuration.
  7. From the menu bar in Directory Utility, choose Edit > Enable Root User, then enter a new password and verify it.
  8. Click on the OK button.

enable root user on Mac

What is sudo in Mac Terminal?

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

How to Enable Root User Using the Directory Utility

  1. Open your Mac’s Spotlight by clicking the menu bar icon in the upper-right corner of the screen or pressing Command + Space.
  2. Search for “directory utility” in the Spotlight window, then select the application when it appears.
Enable Root User Mac Spotlight Directory Utility
  1. Click on the lock icon in the bottom-left corner of the Directory Utility window.
Enable Root User Mac Directory Utility Lock
  1. Use Touch ID or type your Mac password when prompted.
  2. Click on “Edit” in the menu bar and select “Enable Root User” from the drop-down.
Enable Root User Mac Spotlight Directory Utility Edit
  1. A pop-up will appear requesting your root user password. Create or enter your root user password.
Enable Root User Mac Spotlight Directory Utility Root User Password
  1. Click “OK” or press Enter to enable the root user.

How to Log In as the Root User

Once it’s enabled, you can log in to the root account from the login screen.

  1. Log out of your current user account.
  2. Select “Other” on the login screen.
Enable Root User Mac Login Screen
  1. For “username,” enter your username or “root,” then enter the password you created for your root account.
  1. Log in to the account.

To avoid accidental damage to your Mac, you should only log in to the root account when you have a task that specifically requires root privileges.

How to Change the Root User Password

  1. Launch “System Preferences.”
  2. Go to “Users & Groups.”
Enable Root User Mac Change Password System Preferences Home
  1. Click on the lock icon, then enter the administrator name and password to gain access to the underlying settings.
  2. Click on “Login Options” in the sidebar.
Enable Root User Mac Change Password System Preferences Login Options
  1. Click the “Join” button next to “Network Account Server” in the pane on the right.
Enable Root User Mac Change Password System Preferences Login Options Join
  1. Click “Open Directory Utility” in the pop-up that appears.
Enable Root User Mac Change Password System Preferences Login Options Join Directory Utility
  1. Click on the lock icon in the Directory Utility window, then enter your user password or authenticate with Touch ID.
  2. From the menu bar in Directory Utility, choose “Edit,” then select “Change Root Password.”
Enable Root User Mac Change Password Directory Utility 1
  1. Enter a new root password when prompted.

How do you run Terminal in sudo mode?

To enter sudo mode in 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

Enable/disable the root user with Terminal

  1. Open Finder > Applications > Utilities > Terminal, double-click to launch it.
  2. Type one of the commands(the first one for enabling, the second one for disabling) below to manage the root user:
  3. Press Enter and type your password to confirm.

disable root in Terminal

iBoysoft author Amanda Wong

Amanda is one of the main columnists at iBoysoft. She loves exploring new technologies, focusing on macOS, Windows OS, data recovery, data security, disk management, and other tech-related issues. She takes delight in providing technical and informative articles to help people out of problems and get the utmost out of their devices.

Professional tech editor

Jessica Shee is a senior tech editor at iBoysoft. Throughout her 3 years of experience, Jessica has written many informative and instructional articles in data recovery, data security, and disk management to help a lot of readers secure their important documents and take the best advantage of their devices.

Frequently Asked Questions

Can I change the username for the root user account?

Can the password for my Mac and root user be the same?

Is it safe to keep the root user enabled?

Image credit: markusspiske via Pixabay.

Natalie dela Vega

Natalie dela Vega

Natalie is a writer specializing in tech how-tos and gaming. When she’s not writing, she plays PC games and travels. Here at MakeTechEasier, you will see her write about guides, tips, and solutions for Windows and iOS.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Things You Should Know

  • Root privileges lets you open any Mac application with an administrator password.
  • Using root privileges can damage your device if done incorrectly.
  • Limit yourself tasks you understand well to avoid damage to your applications and computer.
  1. Image titled Open Applications With Root Privileges on a Mac Step 2

    • This administrator account must have a non-blank password, or Terminal will not allow you to access root privileges.
  2. Image titled Open Applications With Root Privileges on a Mac Step 3

    • Enter sudo «\file path from hard drive to application.app/Contents/MacOS/application name«.
      For example, to open iTunes, type and press .
    • Enter the password for the administrator account you are currently logged into. Press .
    • If the command works, the application should open with root privileges. If Terminal says «command not found,» continue to the next step.
  3. Image titled Open Applications With Root Privileges on a Mac Step 4

    Open the application’s package contents. If the quick way didn’t work, locate the application in Finder. Right-click (or -click) its icon and select Show Package Contents from the drop-down menu.

  4. Image titled Open Applications With Root Privileges on a Mac Step 5

    Find the executable file. You should now see one or more folders inside the application. Locate the executable file inside this folder. This is usually inside /Contents/MacOS.

    • The executable often has the same name as the application, but it could have another name, such as «run.sh.»
    • The executable file icon is usually a black square with the word «exec» in small letters.
  5. Image titled Open Applications With Root Privileges on a Mac Step 6

  6. Image titled Open Applications With Root Privileges on a Mac Step 7

    Drag the executable file into the Terminal line. This should automatically insert the file path to the executable file.

  7. Image titled Open Applications With Root Privileges on a Mac Step 8

  1. Image titled Open Applications With Root Privileges on a Mac Step 9

  2. Image titled Open Applications With Root Privileges on a Mac Step 10

  3. Image titled Open Applications With Root Privileges on a Mac Step 11

  4. Image titled Open Applications With Root Privileges on a Mac Step 12

  1. Image titled Open Applications With Root Privileges on a Mac Step 13

    • Restart your computer. Hold down + after you hear the start up noise to enter Recovery Mode.
    • Select from the top menu, then .
    • Enter csrutil disable; reboot in Terminal.
    • Let the computer restart as usual. You can now use the steps above to open any application with full root privileges. When you are finished, consider repeating these instructions with instead of to reinstate SIP.
  2. Image titled Open Applications With Root Privileges on a Mac Step 14

    • For example, sudo nano /etc/hosts will open the hosts file with root access.
    • It’s a good idea to make a backup before you edit any configuration files. To do this, enter sudo cp filepath_of_config_file new_filepath of backup. For example, sudo cp /etc/hosts /etc/hosts.backup creates a copy of the hosts file named hosts.backup. If you make a mistake, move the misconfigured file with (for example) sudo mv /etc/hosts /etc/hosts.bad and restore the backup with sudo cp /etc/hosts.backup /etc/hosts.[7]

Add New Question

  • Why does mine say «operation not permitted»?

    Community Answer

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

  • The quotation marks around the file path are only necessary if the file path contains spaces.

Thanks for submitting a tip for review!

How to Enable Root User via the Terminal

You can enable root access via your Mac’s terminal.

  1. To launch the Terminal, either open a new Finder window and navigate to “Applications -> Utilities -> Terminal” or search for “terminal” using Spotlight.
Enable Root User Mac Terminal Finder
  1. In Terminal, type dsenableroot after the “%” symbol and press Enter.
Enable Root User Mac Terminal User Password
  1. Your username should come up. Enter your user password at the prompt and press Enter.
  2. Enter or create your root password and verify it.
  3. You should see a success message indicating that you have enabled the root user.
Enable Root User Mac Terminal Enabled

How to change the root password on Mac?

  1. Choose Apple menu > System Preferences > Users & Groups.
  2. Click the lock icon, then enter your administrator name and password.
  3. Click Login Options, then click Join > Open Directory Utility.
  4. Click the lock icon in the new window, then enter your administrator name and password.
  5. From the menu bar, choose Edit > Change Root Password…, then enter a new root password.

Mac sudo password not working, what to do?

  • 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 cause 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.

Об этой статье

Дополнительно:  How to reset the root password on Ubuntu 22.04 if forgotten
Оцените статью
Master Hi-technology
Добавить комментарий