Mac standard user and sudo command

macterminal

I just got a new MacBookPro. For safety concern, I created one admin user auser and a standard user suser. I am going to use the auser to do all the app installations and suer for normal use.

Something I do need to do some work in the root such as make a new folder in my HD from terminal. As in suser account, I tried this:

$ sudo mkdir /MyApps

I tried to type in password for auser the one for suser, neither seems working. I am not sure what supper user is referring to when a standard user is logged in. Is it root user? Or can a standard user run sudo command?

Best Answer

There's no way to promote yourself directly from a standard user to root unless you make some special preparations: edit /etc/sudoers as @Daniel Beck suggested, create a suid shell (not recommended), etc. There is, however, a way to do it in two steps: use su to switch to your admin account, then sudo to switch to root:

su auser -c "sudo somecommand"

This'll ask for a password twice (unless you've used it in the last 5 minutes, then it'll only ask once); both times it wants the auser password (su always asks for the password of the account you're switching to, while sudo asks for the account you're switching from). BTW, if you run this from a directory that auser does not have read permissions, you'll get an error message ("shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied"), but it will still work.

Related Question