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#
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!

Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!