Apple - Run sudo From Non-Admin Account

Seems like you could use the SU command to switch to another user in Terminal. Once you've switched to the admin user you can use sudo commands coupled with the admin account's password.

For example, when I'm at one of my end user's Macs and I need to run something with elevated privileges (chown for example) without logging out and into the admin account (ladmin) I would use something like this (in bold):

Mr-Rabbits-Mac:~ notadminuser$ su ladmin

This will prompt for the ladmin account's password, once entered you will see a bash command prompt. From here I can run any sudo commands desired, entering ladmin's password as needed...

bash-3.2$ sudo chown user2 /some/folder

This will run the chown command using the now logged in ladmin user, prompting for the ladmin account's password. Once finished you can type exit to return to your logged in user's prompt.

Screenshot of similar process, only using sudo to run the ls command (just for example). enter image description here


Add your existing user name to the sudoers file, and what you need to do is use the visudo command and add lines like this:

User privilege specification

root ALL=(ALL) ALL

<randomuser> ALL=(ALL) ALL

%admin ALL=(ALL) ALL

Or whatever perms you want to give yourself. then you can run sudo whatever to your hearts extent. That's /etc/sudoers by the way.


In Terminal type login, a space, your admin name and hit return. Then type your admin password, hit return and you are logged in as administrator that can issue sudo commands with no additional configuration or files to change.