MacOS – su & sudo on OSX Mavericks

macospasswordsudo

I am trying to use su and sudo on my iMac that I did a fresh clean install of Mac OS X 10.9 and Server 3.0. I explicitly set the password for root with

passwd root

but when I try to use su or sudo from a local network account, it does not accept the password. When I was reading through some of the man pages for su, sudo and passwd, one of them (but I do not remember which) mentioned something about different behavior in an Open Directory environment. I tried digging around but could not find any more info.

Can anyone help me here?

Best Answer

dsenableroot -u $ADMIN_USERNAME -p $ADMIN_PASSWORD -r $ROOTSNEWPASSWORD

replace the variables with your admin username and password as well as the password you desire for root. At that point, you could sudo as the admin user or just su - and use the root password you set to become root.

In the end, you'll want to either configure sudo to allow the commands you use often from your non-admin account or get used to typing the root password when needed.