Enable the root account under OS X using only the command line
I did something stupid this afternoon: I edited my /etc/sudoers files and saved it with a syntax error. I realized there was something wrong when I tried a "sudo" and could not use it. And as I need sudo to edit this file, I thought I was hosed...
Moreover, OS X (client) does not have the root account enabled by default, and I could not find ways to enable it using only the command line, as the machine on which the problem was is back in France, while I'm in Italy. Searching for a while lead me to the following solution, which could be helpful to others.
What you need: command line access to the machine you need to be root on, and an account with administrative privileges. And the key command is "dsenableroot". Assuming your admin account is foo, and you are logged in as foo:
foo@mac ~ % dsenableroot
username = foo
user password:
root password:
verify root password:
dsenableroot:: ***Successfully enabled root user.
As you can see, the user password is asked, and then you enter the root password twice. You can then do whatever you need to (such as edit the /etc/sudoers file) then disable the root account. Assuming you may not be logged in as foo:
bar@mac ~ % dsenableroot -d -u foo
user password:
dsenableroot:: ***Successfully disabled root user.
I hope this is helpful... I was about to call someone to reboot the Mac in single user mode!
0 TrackBacks
Listed below are links to blogs that reference this entry: Enable the root account under OS X using only the command line.
TrackBack URL for this entry: http://alan.petitepomme.net/cgi-bin/mt/mt-tb.cgi/10
Leave a comment