If you come from a Windows background and wondering how to run the CMD equivalent Terminal Console on Mac as administrator, well if elevated permissions are required for the default Mac user (who usually is an admin), you will be asked to enter your password.
Example let's say you are trying to remove a directory or install a new software package from the Terminal, you will be prompted for your password.
% rm -r mydir
password:
The root user and sudo command
In Windows we have the administrator user who can perform actions requiring elevated privileges. Along the same lines, a Unix-based operating system such as macOS or Linux, has the root user.
On Windows when you want to elevate the command prompt, you right-click on it and choose "Run as administrator", on the Mac Terminal you will make use of the sudo before any command you run.
Example:Here the dev user do not have the permission to do run cd command to access it as it belongs to the user c2ctech Desktop.
dev@C2C-Tech-Mac c2ctech % cd Desktop
cd: permission denied: Desktop
Simply add sudo at the start of the command and you should be able to access it (provided you are part of the sudoers file)
dev@C2C-Tech-Mac c2ctech % sudo cd Desktop
How to switch to root user
One other way is to switch to the root user to get the admin privileges and you can run all commands using that user.
Example:% Code2care@Mac % sudo su -
Password:
C2C-Tech-Mac:~ root#
![Switch to root or admin user Mac Terminal Switch to root or admin user Mac Terminal](https://code2care.org/macos/run-terminal-as-admin-on-mac/images/Switch to root or admin user Mac Terminal.jpg)
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Fix: grunt: command not found (Mac/Windows)
- AppleScript Example with TextEdit
- How to copy Password of Wifi on your Mac
- Install OpenJDK Java (8/11/17) versions using brew on Mac (Intel/M1/M2)
- How to check if a port is in use using terminal [Linux or macOS]
- Cut, Copy and Paste Keyboard Shortcuts on Mac Keyboard
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required.
- How to Remove Widgets from macOS Sonoma 14 Desktop
- Turn off Auto-Capitalization on macOS Ventura 13
- How to Go To /usr/local/bin on Mac Terminal?
- How to Open TextEdit on Mac
- Mac: How to Open Android Studio from Terminal
- How to change the default location of Mac Screenshot
- Display Seconds in Digital Clock on Mac Menu Bar [macOS]
- How to install homebrew (brew) on M1 Mac
- Must Know Homebrew Commands for Mac/Linux Users
- Steps to Uninstall Roblox on Mac (macOS)
- How to change the System Settings Sidebar icon size Mac Ventura 13
- How to set Out Of Office (OOO) on Outlook for Mac [Updated 2023]
- Trigger Notification Center Message using Mac Terminal Command
- [fix] macOS Ventura - Python3 xcrun: error: invalid active developer path missing xcrun at CommandLineTools
- How to Install Rust Language on Mac (macOS)
- How to minimize all Windows in Mac
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- How to make TextEdit the default text Editor on Mac
- How to submit website to dmoz directory - HowTos
- Convert String to LocalDate in Java - Java
- 47: Take a list of strings and print each string. [1000+ Python Programs] - Python-Programs
- 0xCAA20003: You ran into an authorization problem. [Microsoft] - Microsoft
- How to detect Operating System using Java code - Java
- How to copy file name and path to clipboard in Notepad++ - NotepadPlusPlus
- Spring Boot AI + LLM + Java Code Example - Java
- Ping IP/Server Address using Python Example - Python