NickC
NickC

Reputation: 35

Mac Terminal Promote User to admin group while User

How do I promote UserB to be an admin while I am logged in as that user?

I have tried:

Machine:~ UserB$ su UserAdmin /usr/bin/dscl . -append /Groups/admin GroupMembership UserB                                                       
Password: UserAdminsPassword                                                                                                                                                     
/usr/bin/dscl:6: parse error near `)'                                                                                                                          
Machine:~ UserB$  

I have also tried a ton of other things with other quotes or prens or creating a bash script and calling.

This is on a Mac running Catalina.

Upvotes: 0

Views: 2585

Answers (1)

MacDefender
MacDefender

Reputation: 346

Try the following:

su UserAdmin -c 'sudo dscl . -append /Groups/admin GroupMembership UserB'

If your UserAdmin has a normal admin account it is not allowed to use dscl directly. So after switching to the UserAmin account with su UserAdmin another sudo is required for that UserAdmin to call dscl as root.

In your example there is also a -c missing as the rest of the command line is a command to execute and not additional arguments for the shell of the user you are switching to.

Upvotes: 2

Related Questions