Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

You need to run sudo visudo from your admin account and add an entry for your regular user account to allow performing sudo.

man sudoers and man visudo will tell you how to do that exactly. In short:

Add a line like the following to allow your regular user with short name shortname to perform everything:

shortname ALL=(ALL) ALL

You can restrict this to specific commands by replacing the last ALL to the names of programs allowed to run, e.g. /bin/mkdir.

share|improve this answer
    
I don't have my Mac to test it out right now. Do you mean that my auser is not in dudoers file in my case (new Mac)? By using this command I can add an admin user to sudoers? –  David.Chu.ca May 18 '11 at 21:13
    
No, not the admin, but rather the standard user. The admin is a sudoer by default. –  slhck May 18 '11 at 21:16
    
@David Regular non-admin users are not allowed to use sudo — by default, only members of the wheel group (Administrator users) are allowed to use sudo. By doing what I suggest, you add that permission. That's why editing /etc/sudoers by invoking visudo needs to happen from your admin account auser. –  Daniel Beck May 18 '11 at 21:18
    
Sounds not the right thing to do if I give the permission for the normal user with more power. Just accept the fact and do as admin if needed. –  David.Chu.ca May 18 '11 at 21:19
    
@David Consider using su - auser then, and entering that user's password. I'm not 100% certain, but I think this is possible even from regular user accounts. This'll open a login shell for the auser account, allowing you to run commands as auser. –  Daniel Beck May 18 '11 at 21:22

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.