MacOS – Using Command Line how to make the user an Administrator

administratorcommand linemacos

As soon I bind a Mac to the AD Domain, I usually log into the Mac with the user account.

Of course, under System Preference, User & Groups, the user account is marked as: Managed, Mobile

My second step, is to make the user an Administrator account because I want to allow him/her to install/remove stuff from her/his Mac.

So, with the GUI, System Preferences > Users & Groups > I select the user name and I check mark the option: enable Allow user to administer this computer and I restart the machine and everything works fine. The user now is an Admin for that machine.

Question, how do I perform the above process with the command line in Terminal? Not the bind process, but to make the user Admin for that specific machine.

Best Answer

sudo dscl . -merge /Groups/admin GroupMembership username

where ‘username’ is the username of the user you would like to make an admin.

sudo since making changes like this requires elevated privileges.
dscl is the Directory Service command line utility.
. is the local machine.
-merge allows you to add a new key to a record path.
/Groups/admin is the record path for the key.
GroupMembership is the key you would like to assign a value.
username is the value for the key.