Create new user using command line

yjian
New Contributor III

Hi, 

 

How can I create new admin user using command line and user home will be delete automatically when remove from System Preferences?

I successfully create new admin user using the following command but when I delete this user from system preferences the home folder will not delete automatically compare to users create manually from system preferences.

Any advice?

Thank you

sudo sysadminctl -addUser Admin -fullName "Admin" -password admin123 -home /Users/admin -shell /bin/zsh -admin

1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

@yjian Have you tried using the sysadminctl command without the -home option? Specifying the home directory is optional, and if you do specify a home path instead of allowing the sysadmin to create a home directory in the default location (which is what you appear to be trying to do) it may be treated differently when it comes to deletion.

View solution in original post

1 REPLY 1

sdagley
Esteemed Contributor II

@yjian Have you tried using the sysadminctl command without the -home option? Specifying the home directory is optional, and if you do specify a home path instead of allowing the sysadmin to create a home directory in the default location (which is what you appear to be trying to do) it may be treated differently when it comes to deletion.