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

Nov 1, 2016 - 4 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

4 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.

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