daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Oct 16th, 2017 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dscl . -create /Users/luser
  2. dscl . -create /Users/luser UserShell /bin/bash
  3. dscl . -create /Users/luser RealName "Lucius Q. User"
  4. dscl . -create /Users/luser UniqueID "1010"
  5. dscl . -create /Users/luser PrimaryGroupID 80
  6. dscl . -create /Users/luser NFSHomeDirectory /Users/luser
  7.    
  8. dscl . -passwd /Users/luser password
  9.    
  10. dscl . -append /Groups/admin GroupMembership luser
  11.    
  12. maxid=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)
  13. newid=$((maxid+1))
  14.    
  15. cp -R /System/Library/User Template/English.lproj /Users/luser
  16. chown -R luser:staff /Users/luser
  17.    
  18. sudo dscl . list /Users uid
  19.  sudo dscl . list groups gid
  20.    
  21. #!/bin/bash
  22. # This script creates a user account under Mac OS X
  23. # (tested with 10.5 and 10.6; likely works with 10.4 but not earlier)
  24. # Written by Clinton Blackmore, based on work at
  25. # http://serverfault.com/questions/20702
  26.  
  27. # === Typically, this is all you need to edit ===
  28.  
  29. USERNAME=joeadmin
  30. FULLNAME="Joe Admin"
  31. PASSWORD="hard_to_hack"
  32.  
  33. # A list of (secondary) groups the user should belong to
  34. # This makes the difference between admin and non-admin users.
  35. # Leave only one uncommented
  36. #SECONDARY_GROUPS=""  # for a non-admin user
  37. SECONDARY_GROUPS="admin _lpadmin _appserveradm _appserverusr" # for an admin user
  38.  
  39. # ====
  40.  
  41. if [[ $UID -ne 0 ]]; then echo "Please run $0 as root." && exit 1; fi
  42.  
  43. # Find out the next available user ID
  44. MAXID=$(dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1)
  45. USERID=$((MAXID+1))
  46.  
  47. # Create the user account
  48. dscl . -create /Users/$USERNAME
  49. dscl . -create /Users/$USERNAME UserShell /bin/bash
  50. dscl . -create /Users/$USERNAME RealName "$FULLNAME"
  51. dscl . -create /Users/$USERNAME UniqueID "$USERID"
  52. dscl . -create /Users/$USERNAME PrimaryGroupID 20
  53. dscl . -create /Users/$USERNAME NFSHomeDirectory /Users/$USERNAME
  54.  
  55. dscl . -passwd /Users/$USERNAME $PASSWORD
  56.  
  57.  
  58. # Add use to any specified groups
  59. for GROUP in $SECONDARY_GROUPS ; do
  60.     dseditgroup -o edit -t user -a $USERNAME $GROUP
  61. done
  62.  
  63. # Create the home directory
  64. createhomedir -c > /dev/null
  65.  
  66. echo "Created user #$USERID: $USERNAME ($FULLNAME)"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top