How to open apps with root privileges on a Mac

Author: Louise Ward
Date Of Creation: 11 February 2021
Update Date: 28 June 2024
Anonim
How To Enable Root User On Mac OS
Video: How To Enable Root User On Mac OS

Content

You can open any Mac application with advanced administrator privileges (root privileges), as long as you have an administrator password. As usual, do not use advanced access unless you know what you are doing, otherwise you could cause a fatal error in the application or computer.

Steps

Method 1 of 3: On the admin account

  1. Know the risks. Most graphics apps are not designed for premium access. Limit yourself to specific tasks that you understand, otherwise you will make data inaccessible, application crashes or security holes.

  2. Open Terminal. Log in as an administrator on the computer. Go to Applications → Utilities and launch Terminal.
    • The administrator account must have a non-blank password, otherwise Terminal will not give you root access.

  3. Try faster. The sudo command allows us to launch applications with top-level access, but this requires the path to the executable in the application package. Most Mac apps with many third-party programs have similar package arrangements, so give it a try:
    • Enter sudo "file path from hard drive to application.app / Contents / MacOS /application name’.
      For example, to open iTunes, type sudo "/Applications/iTunes.app/Contents/MacOS/iTunes" and press ⏎ Return.
    • Enter the administrator account password that you normally log in with. Press ⏎ Return.
    • If the command works then the app will open with premium access. If the Terminal says "command not found", continue to the next step.

  4. Open the contents of the application package. If the quick opening doesn't work, look for the app in the Finder. Right click (or press Control and click) on the app icon and select Show Package Contents from the drop-down menu.
  5. Find the executable. You should see one or more folders inside the app. Look for the executable in the directory. This file is usually located in / Contents / MacOS path.
    • The executable usually has the same name as the application, but it can also be a different name, such as "run.sh."
    • The executable usually has a black square icon with a little "exec" inside it.
  6. Enter the sudo command into Terminal. Enter sudo followed by a space. Don't enter now.
  7. Drag the executable and drop it on the Terminal command line. The path to the executable will be inserted automatically.
  8. Confirm the order with a password. Press ⏎ Return. Enter the administrator account password that you used to log in, click ⏎ Return Again. The app will launch with premium access. advertisement

Method 2 of 3: On the non-admin account

  1. Open Terminal with a non-admin account. Many administrators prefer to work on regular user accounts to limit the possibility of causing bugs or being attacked by malware. This method still requires an administrator password, but allows you to gain temporary top-level access without switching accounts. To get started, open a Terminal window.
  2. Switch to administrator rights on Terminal. Enter the command su - followed by a space and the username for the computer's administrator account. Enter the password of this administrator account. So you will act like that user.
    • Hyphens in the command are optional, but recommended. It sets the environment variable and directory for this admin user and will limit the possibility of inadvertently making the error.
  3. Open the application with the sudo command. The most common way to do this is to type sudo "file path from hard drive to application.app / Contents / MacOS /application name". If this doesn't work, or you need more guidance, see the instructions for using the administrator account above.
  4. Go back to your account. After you complete the tasks that require root access, type exit on Terminal. This command will quit the administrator account and return to your regular account. advertisement

Method 3 of 3: Troubleshooting

  1. Disable System Integrity Protection (SIP). This feature (introduced on Mac OS 10.11 El Capitan) will limit access to important data even for advanced users. If you can't make the changes you want, disable SIP. Note that the risk for this approach is very high. You should only apply this if you feel confident in your abilities and remember that if an error occurs, the computer will be wiped, even unable to function:
    • Restart the computer. Hold down ⌘ Command + R after you hear the boot sound to access Recovery Mode.
    • Choose Utilities from the top menu, then Terminal.
    • Enter csrutil disable; reboot into Terminal.
    • Let the computer restart as usual. Now you can apply the steps above to open any app with root privileges. Once done, consider re-executing these instructions with the command enable instead of disabling in order to restore the SIP.
  2. Use nano instead of a graphical text editor. This option will be more secure and reliable in editing configuration files using a text editor right from the Terminal. Nano is the simple option available by default. To use this feature with advanced access, simply type sudo nano, followed by a space and a path to the text document. You can then edit the document right from the Terminal. When finished editing, press Control + O to save then press Control + X to exit nano.
    • For example, the command sudo nano / etc / hosts will open the server file with elevated level permissions.
    • It is recommended that you make a backup before editing any configuration files. To do this, enter sudo cp filepath_of_config_filenew_filepath of backup. For example, the command sudo cp / etc / hosts /etc/hosts.backup will make a backup copy of the host file as hosts.backup. If you make a mistake then you can move the misconfigured file using sudo mv / etc / hosts /etc/hosts.bad (for example with the hosts.backup file) and restore the backup with the sudo command. cp /etc/hosts.backup / etc / hosts.
    advertisement

Advice

  • The quotes before and after the path are only necessary if the path contains spaces.

Warning

  • A single error using advanced access can wipe your computer clean or shut it down. This risk is even higher on version 10.10 and earlier, or on version 10.11 when SIP is disabled. You should restrict sharing your administrator password to prevent others from taking root privileges.