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#
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
- How to show line numbers in Nano on Mac
- How to install Jupyter Notebook on macOS Sonoma
- How to Disable Remote Management using Mac Terminal
- Test internet speed using macOS Terminal command
- Docker Desktop needs privileged access macOS
- Google Search Hot Trends Screensaver for Mac OS X
- How to do calculations in Mac Terminal
- How to make TextEdit the default text Editor on Mac
- How to Show Full Website Address on Safari for Mac (Ventura/Sonoma)
- The Zsh Shell - Mac Tutorial
- Opening mac Terminal
- How to change the name of your Mac running on macOS Ventura 13
- How to find the Battery Cycle Count on macOS Ventura
- How to set an emoji as Zsh terminal prompt in macOS
- How to access Trash Folder using Mac Terminal Command
- macOS Ventura XCode Command Line Tools Installation
- Hide Bluetooth icon on Mac Menu Bar macOS Ventura 13
- How to run .sh file in Mac Terminal
- Terminal Command to get the list of available shells in macOS
- How to see Storage Information on macOS Ventura
- How to Go To /usr/local/bin on Mac Terminal?
- How to do screen recording on Mac
- How to Find File and Directory Size in Mac Terminal
- Open .bash_profile File in TextEdit using Terminal
- Remove Now Playing icon from macOS Big Sur Menu Bar
- Command to know the installed Debian version? - Linux
- Make Android View Scrollable both Horizontally and Vertically - Android
- How to Know Version of Windows Terminal - Windows
- Installing vue.js in Laravel 8 - PHP
- Python: Determine Variable Type Example - Python
- How to format or prettify XML in Notepad++ - NotepadPlusPlus
- How to Subscribe to Google Nest Aware on iPhone - Google
- Get count of SharePoint List or Document Library Items using PowerShell - SharePoint