Convert Standard User Account to Administrator Account from Command Line of Mac OS
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.
How to Change 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.