Monday, December 8, 2014

create a user via commandline in osx

 create a local user with local user group in macos x  
   
 list existing local gids:  
 # dscl . -list /Groups PrimaryGroupID | awk '{print $2}' | sort -n  
   
 for new group, choose numeric id not in list; above 1000 is good.  
 # dscl . -create /Groups/localgroup  
 # dscl . -create /Groups/localgroup PrimaryGroupID 1001  
   
 did you press enter?  
   
 # dscl . -read /Groups/localgroup  
   
 AppleMetaNodeLocation: /Local/Default  
 GeneratedUID: 00A738DA-21B7-4CD2-B5D9-7873C77205D1  
 PrimaryGroupID: 1001  
 RecordName: localgroup 
 RecordType: dsRecTypeStandard:Groups  
   
 list existing local uids:  
 # dscl . -list /Users UniqueID | awk '{print $2}' | sort -n  
   
 for new user, choose numberic id not in lists; above 1000 is good.  
 # dscl . -create /Users/localuser  
 # dscl . -create /Users/localuser UserShell /bin/bash  
 # dscl . -create /Users/localuser RealName "Local Users"  
 # dscl . -create /Users/localuser UniqueID "1001"  
 # dscl . -create /Users/localuser PrimaryGroupID 1001  
 # dscl . -create /Users/localuser NFSHomeDirectory /Users/localuser  
   
 did you really do all that?  
   
 # dscl . -read /Users/localuser  
   
 AppleMetaNodeLocation: /Local/Default  
 NFSHomeDirectory: /Users/localuser  
 GeneratedUID: 47D6D841-C7F1-4962-9F7E-167E8BFC3A91  
 PrimaryGroupID: 1001  
 RealName: localuser  
 RecordName: localuser  
 RecordType: dsRecTypeStandard:Users  
 UniqueID: 1001  
 UserShell: /usr/bash  
   
 create home directory.  
 # mkdir /Users/localuser  
 # chown localuser:localgroup /Users/localuser  
   
 give localuser a password:  
 # password localuser  
   
 # su - localuser  
   
 $  
   
 neat!  
   

No comments: