Using an OS X system and having the administrative password, you can start any application with the privileges of the "root" user account. As always, it is best to avoid using this access level if you do not know what you want to do, since an error could have very serious consequences for the security and integrity of the data and of the entire system.
Steps
Method 1 of 3: Use a System Administrator Account
Step 1. Learn the risks you face
Most graphical applications do not need the "root" account to be used. Limit yourself to using the computer to carry out all those activities you master; do not face problems or situations that are beyond your reach, otherwise you could make important files inaccessible, compromise the normal functioning of applications or create security vulnerabilities of the whole system.
Step 2. Open a "Terminal" window
Log in using a system administrator account. Access the Applications and Utilities folders in succession, then start the Terminal app.
The administrator account you want to use must have an access password set because otherwise the "Terminal" application will not allow you to use it to get the privileges of the "root" account
Step 3. Try the fastest way
The sudo command allows you to start applications with the access privileges reserved for the "root" account. In this case, the full path to the executable file is required, which is located within the application package. Most of the default applications of the OS X operating system, as well as many third-party programs, organize files within their respective packages in the same way, so it's worth trying to use this command:
-
sudo "\ full_path + application_package_name.app / Contents / MacOS / application_name".
For example, to start iTunes, you would type the command sudo "/Applications/iTunes.app/Contents/MacOS/iTunes", then press Enter.
- Enter the password of the administrator account you logged into the system with, then press the Enter key.
- If the command works, you will see the application window open with the access privileges of the "root" account. If the message "command not found" appears in the "Terminal" window, continue reading the article.
Step 4. Access the package contents of the application you wish to launch
If the method explained in the previous step did not work, locate the desired application using Finder. Select the relative icon with the right mouse button (if the pointing device has only one button, hold down the Control key while clicking), then choose the Show package contents item from the context menu that appears.
Step 5. Locate the executable file
You should now be able to see one or more folders within the application package. Search for the app's executable file within these directories. Generally, it is contained within the "/ Contents / MacOS" folder.
- Often the executable file is named with the same name as the application it refers to, but it could still have any name, such as "run.sh".
- Normally, executable files have a black square icon with the word "exec" inside.
Step 6. Use the sudo command within a "Terminal" window
Type the command sudo followed by a blank space. Don't press the "Enter" key just yet.
Step 7. Drag the executable file icon into the "Terminal" window
This way the above command should automatically complete with the full path of the selected file.
Step 8. Provide the admin password
Press the Enter key. Type the password of the administrator account you are currently logged into the computer with, then press the Enter key again. The indicated application should start with the access privileges of the "root" user account.
Method 2 of 3: Use a Normal User Account
Step 1. Launch a "Terminal" window using a user account without administrative rights
Normally many IT administrators prefer to work with normal user accounts to limit the risk of causing damage due to human error or malware. While using this procedure, it is still necessary to use the access password of an administrator account on the computer, with the difference, however, that the privileges of the "root" profile will be acquired only temporarily and without the need to log in to the system with another account. As a first step, open a "Terminal" window.
Step 2. Switch to using a system administrator account within the "Terminal" window
Type the command su -, followed by a blank space and the name of the administrator user profile of your computer. At this point, provide the login password. You are now using the current "Terminal" window with the privileges of the provided profile.
Using the "-" symbol in the above command is optional, but recommended. Using it, the environment variables and folders related to the administrator account in use will be configured, thus limiting the possibility of causing unintentional damage
Step 3. Start the desired application using the sudo command
The normal syntax is sudo "\ full_path + application_name.app / Contents / MacOS / application_name". If this command doesn't work or you need more assistance, please refer to these instructions.
Step 4. Restore the use of your normal user account
After completing all the tasks that required the privileges of the "root" user account, type the command exit in the "Terminal" window. This will cause you to lose your computer administrator privileges and resume using your normal user account.
Method 3 of 3: Troubleshooting
Step 1. Disable the "System Integrity Protection" feature (very risky activity)
This feature was introduced in OS X 10.11 El Capitan and restricts access to important files even by the "root" user. If you are unable to make changes related to your needs, you can disable the "System Integrity Protection" feature. Since a mistake could render your computer unusable or cause you to lose all stored data, only proceed if you are an experienced user and know exactly what you are about to do.
- Restart your computer. After hearing the beep of the start of the system boot procedure, hold down the ⌘ Command + R keys to enter "OS X Recovery" mode.
- Select the Utilities item from the menu at the top of the screen, then choose the Terminal option.
- Type the command csrutil disable; reboot inside the "Terminal" window that appeared.
- Wait for the computer to restart normally. Now you can use the steps described at the beginning of the article to start any application with "root" user privileges. At the end of the work, decide whether to reactivate the "System Integrity Protection" feature by replacing the disable parameter with enable within the previous command.
Step 2. Use the "nano" text editor instead of a graphic one
Using the built-in text editor in the "Terminal" window to edit the contents of the system configuration files may be more secure and reliable. The "nano" editor is a simple and easy to use tool; moreover, it is already integrated into the operating system. To use it with the privileges of the "root" user account, simply type the command sudo nano followed by a blank space and the full path to access the text file to be edited. At this point, you can edit the desired document directly from the "Terminal" window, according to your needs. When finished, press the key combination Control + O to save the changes and Control + X to close "nano".
- For example, the sudo nano / etc / hosts command displays the contents of the "hosts" file with the access privileges of the "root" account.
- Before modifying a system configuration file in any way, it is best to make a backup copy of the file in question. To do this, type the command sudo cp full_path_to_file full_path_copy_of_backup. For example, the sudo cp / etc / hosts /etc/hosts.backup command creates a copy of the "hosts" file called "hosts.backup". If you make a mistake while editing the file, you can fix it by using the backup copy in this way: following the example above, use the command sudo mv / etc / hosts /etc/hosts.bad to rename the corrupt file, then restore the backup copy via the command sudo cp /etc/hosts.backup / etc / hosts.