Convert Standard User Account to Administrator Account from Command Line of Mac OS

Nov 1, 2016 - 8 Comments

Change User to Admin Account from command line of Mac OS X

Mac systems administrators may find a need to convert an existing regular user account into an administrator account on a Mac. While most Mac users would be best served by converting account status to admin through the Users & Groups preference panel, advanced users can perform the same function through the Terminal by using the Directory Service command line utility dscl.


Note this change will have no impact on the ability for any user account, admin or standard, to access the sudo function, or use the root account, both of which are entirely separate from an administrator account in Mac OS X.

Changing a User to Admin at Command Line in Mac OS X

You’ll need the regular user accounts short user name to switch it to an administrator account, the rest is handled at the command line. If you aren’t certain of the short user name for the target account, you can use this to list accounts on the Mac, or take a look in the /Users/ directory.

When you have the username, launch Terminal and use the following command to change the account to admin:

dscl . -append /groups/admin GroupMembership USERNAME

For example, with a short user name of “paul” the syntax would be:

dscl . -append /groups/admin GroupMembership paul

Upon executing the proper command, the targeted user account will now have administrator privileges and all access abilities that go with an admin account.

This can be particularly helpful for remote administration with ssh and automated setup situations, but it’s also handy in that you can switch a user account to administrator privilege from Single User Mode and when booted from Recovery Mode as well.

Confirm the Change and View a List of All Administrator Accounts in Mac OS X

You can confirm the user account has been converted to the administrator group by using the -read flag with dscl on the same group:

dscl . -read /groups/admin GroupMembership

This should print something back like:

“osxdaily paul adminaccount” or similar, depending on the account(s) which belong to the admin group. The list will only include administrator accounts, whereas other commands will list all user accounts on a Mac.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks

8 Comments

» Comments RSS Feed

  1. Jaap says:

    How to reverse?
    My own user account has admin priviliges.
    Long ago I devined a special “admin” account to avoid having to type in the password after “wakening up” in my own account. It seems now that that is only necessary when starting the computer or changing users, so I want to delete that special account (part of cleaning up things), but I cannot delete that status or account, not in my own (admin) account nor in that “admin” account. I wonder is there a way?

  2. Corey says:

    You should also be able to delete the user from the admin group by entering.

    sudo dscl . -delete /groups/admin GroupMembership USERNAME

    also keep in mind these commands have to be run with Sudo unless your logged in as the root user.

  3. Daniel Acevedo says:

    Hi my only account is an standard account, I don’t have a user name for the administrator user, I can’t log in anymore or make changes that require administrator permission. I’ve tried this but it doesn’t work, do you know what I can do?

  4. Dona says:

    Have the same issue with Daniel Acevedo. Please help us to fix this

  5. Dona says:

    I already fixed my issue. Here’s how to do it

    Turn off your macbook > hold command + S then turn on (hold still until terminal appears) at the very end input these commands;

    mount -uw / (press enter)
    rm /var/db/.AppleSetupDone (enter)
    ‘reboot’

    Note: make sure that you don’t insert an space bar between / and .AppleSetupDone
    Make sure also you input the right commands with their proper cases because it is case sensitive.

    Hope it will works with yours too.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Recent Posts