Showing posts with label dscl. Show all posts
Showing posts with label dscl. Show all posts

Tuesday, February 1, 2011

Restoring admin rights

I've not had a reason to do this recently, but was curious so I decided to try. I wanted to give myself admin rights from the command line, specifically single user mode.

For those of you who don't know, single user mode is a command line only way to interact with the system as root, in most cases its possible without a password. Hold command+s when booting and see what it looks like! (if you get scared, just type "exit")

Once in single user mod (SUM), you can interact with the system by using commands. So, in this case, I want to add my user "rusty" to the admin group on the machine... This is what I did.

First, start computer in SUM - hold command+s at boot

Second, after you see the prompt (root#) type "/sbin/mount -uw /" (there are two spaces in there, its important not to loose them!)
Hit Return.

Third, I need to start the Directory Services, I do so by typing:
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
Hit Return.

Fourth, Now that Directory Services is started, I can make the appropriate changes use dscl.
To add my "rusty" account to the admin group, I use:
dscl . append /Groups/admin GroupMembership rusty

Fifth,
Once you are done making changes, exit SUM using the command "exit"

There are lots of other cool tricks with dscl, give it a try and post some of your favorites!