Creating a local user through Terminals

Discussion in 'OS X El Capitan (10.11)' started by ferko86, Feb 22, 2017.

  1. ferko86 macrumors newbie

    ferko86

    Joined:
    Feb 22, 2017
    Location:
    Sweden
    #1
    When i create a local admin user on OSX , i get everything OK , BUT i cant make any changes on the System Preferences , cant change TrackPad settings , cant change NADA .
    It looks good when i check the users permissions .

    the user that got this problem have the name "userbad" .
    when I look at /Users/userbad/Library/Preferences there is nothing but only one file (.plist)

    when i look at "usergood"
    /Users/usergood/Library/Preferences there are tons of .plist files .
    inside usergood account I can adjust/change as normally inside the systempreferences icon.

    I assume that it have to do with some inheritance-issue while creating the new account , or am I wrong ?

    Anybody that can figure it out ?

    The commands i used when creating the username :

    Code:
    dscl . create /Users/userbad
    dscl . create /Users/userbad RealName "userbad1"
    dscl . passwd /Users/userbad kotte
    dscl . create /Users/userbad UniqueID "590"
    dscl . create /Users/userbad PrimaryGroupID 20
    sudo cp -R /System/Library/User\ Template/English.lproj /Users/userbad
    dscl . create /Users/userbad UserShell /bin/bash
    chown -R userbad:staff /Users/userbad
    sudo dseditgroup -o edit -a userbad -t user admin
    sudo dseditgroup -o edit -a userbad -t user wheel
     
  2. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #2
    You haven’t assigned the user directory.
    Code:
    NFSHomeDirectory: /Users/userbad
    Don’t add the user to the wheel group. On macOS, that group is reserved for root. You should also add it to the ‘staff’ group.
     
  3. ferko86 thread starter macrumors newbie

    ferko86

    Joined:
    Feb 22, 2017
    Location:
    Sweden
    #3
    Hi KALLT , thanks for the reply .

    I cant get this script working when working with variables . But i i will try it .
    I'll come back tp you owith results.
     
  4. ferko86 thread starter macrumors newbie

    ferko86

    Joined:
    Feb 22, 2017
    Location:
    Sweden
    #4
    Hi KALLT ,

    this is the scrip im trying to use ,
    Code:
    #!/bin/sh
    USERNAME=name1
    FULLNAME=name1namn
    PASSWORD=”name1123”
    GROUPS=”staff”
    
    # Find out the next available user ID
    MAXID=$(dscldscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)
    USERID=$((MAXID+1))
    echo ”$USERID”
    
    
    # Create the user account
    dscl . -create /Users/$USERNAME
    dscl . -create /Users/$USERNAME UserShell /bin/bash
    dscl . -create /Users/$USERNAME RealName "$FULLNAME"
    dscl . -passwd /Users/$USERNAME $PASSWORD
    dscl . -create /Users/$USERNAME UniqueID "$USERID"
    dscl . -create /Users/$USERNAME PrimaryGroupID 20
    dscl . -create /Users/$USERNAME NFSHomeDirectory /Local/Users/$USERNAME
    sudo dseditgroup -o edit -a $USERNAME -t user admin
    
    # Create User HomeFolder using OS X’s own template
    sudo cp -R /System/Library/User\ Template/English.lproj /Users/$USERNAME
    
    # Change owner of the home folder to our new user
    chown -R $USERNAME:staff /Users/$USERNAME
    
    # Set permissions so that only our user(the owner) can access the folder
    chmod -R 600 /Users/$USERNAME
    
    # Output message
    echo "Created user #$USERID: $USERNAME ($FULLNAME)"
    printf ”dscacheutil -q user | grep -A 3 -B 2 -e uid:\ 5’[0-9][0-9]’”
    
    #Output results to a file
    system_profiler >> /Users/name1/Desktop/report.txt
    whenever i Run the script , the new user account's full name appear as blank in the login user list.
     
  5. KALLT macrumors 601

    Joined:
    Sep 23, 2008
  6. ferko86 thread starter macrumors newbie

    ferko86

    Joined:
    Feb 22, 2017
    Location:
    Sweden
    #6
    Hi KALLT , i have rebooted several times.
    for the moment i've been given up :) . i'll see if I can continue with the scripting....
     

Share This Page