Benches macOS

1

Change user type with terminal

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hi all,

I am trying to find the commands' to be able to change a 'Service' user from an Admin user to a standard user. I have found ways to do it via single user mode however i would like to be able to do this with terminal as i will be using remote desktop to change all the service users in my company. Any help would be great

Cheers

1 reply

Sign in or join Beachball Help to reply.

  1. 0

    TJPile

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I can't take full credit for this. I found it at:

    http://farbflash.de/cgi-bin/blosxom.cgi/?find=snippets

    I did, however, know the command to look for.

    The commands necessary to create an admin user are as follows:

    sudo -s

    niutil -create . /users/username

    niutil -createprop . /users/username passwd ""

    niutil -createprop . /users/username home /Users/username

    niutil -createprop . /users/username shell /bin/tcsh

    niutil -createprop . /users/username uid 520

    niutil -createprop . /users/username gid 20

    niutil -createprop . /users/username realname "First Last" - if this property is not created, the user won't appear in the loginwindow!

    niutil -appendprop . /groups/admin users username - only for admin users!

    These below are optional:

    niutil -createprop . /users/username hint "password hint"

    niutil -createprop . /users/username
    writerspassword username

    niutil -createprop . /users/username
    writershint ""

    niutil -createprop . /users/username
    writerspicture username

    niutil -createprop . /users/username sharedDir Public

    exit

    There needs to be a valid home directory, shell, and/or SharedDir for the user. A home directory can be created as easily as:

    sudo mkdir /Users/username

    sudo chown username:staff /Users/username

    Or if you want the default OS X user directory structure:

    sudo cp -rp /System/Library/User Template/English.lproj /Users/username

    sudo chown -R username:staff /Users/username

    (/System/Library/User Template also has other localized language templates)

    Additional info:

    To change an admin user back to an ordinary user:

    sudo niutil -destroyval . /groups/admin users username

    Be careful to leave at least one accessible admin user, otherwise you will lock yourself out of your machine.

    after changing netinfo:

    sudo niutil -resync .

    log out and in the user you changed.