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#

Have Questions? Post them here!
- How to find path of file on Mac Terminal
- How to disable Siri on Mac Monterey
- [fix] macOS Ventura xcrun: error: invalid active developer path missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
- Select Line Number TextEdit on Mac
- Go to Specific file path using Mac Finder
- How to find Java HOME in Mac Terminal
- bash: command not found error [macOS Terminal Linux, Unix or Windows]
- Must Know Homebrew Commands for Mac/Linux Users
- How to Insert an Inverted Question Mark on Mac ¿
- Hide Keyboard Text Input Icon on macOS Ventura Menu Bar
- How to make macOS Terminal window Transparent (or Opaque)
- How to check of Updates on Microsoft Edge Browser on Mac (macOS)
- Limit scrollback rows in macOS Terminal
- How to identify installed Java (JDK) Version on macOS
- Keyboard Shortcut to delete a file on a Mac [Macbook]
- Open Docker from Terminal Command on Mac
- Installing MongoDB on Linux/Unix/macOS/Ubuntu
- How to take a screenshot on a Mac - updated for Ventura 13 [updated 2023]
- ls: .: Operation not permitted - Mac Terminal ZSH Error
- How to remove username from Mac Menu Bar?
- macOS Ventura XCode Command Line Tools Installation
- Where is .zshrc file located in macOS
- How to Show Path of Files or App in Mac Spotlight Search
- How to enable root user on Mac Terminal
- Install Java 17 (LTS) JDK on ARM based M1/M2 Mac Natively
- Spring Boot CRUD Examples using JDBCTemplate - Java
- How to always show Bookmarks bar on Google Chrome Browser - Chrome
- Install Microsoft OneDrive on Mac - MacOS
- How to check if Java main thread is alive - Java
- Hide Navigation Bar from Android Screen Activity - Android
- How to make a Android button act as a toggle button - Android
- How to copy Chrome alert popup text to clipboard - Chrome
- Fix mySQL Error Cant connect to local MySQL server through socket /var/run/mysqld/mysqld.sock ERROR 2002 HY000 - MySQL