понедельник, 3 марта 2014 г.

Mac OS X: Create user, Create group, Add user to group, Change password from terminal

List existing group IDs in numerical order to choose an unused one for new group :-
$ dscl . -list /Groups PrimaryGroupID | awk '{print $2}' | sort -n
Create the new group 'newgroup' and assign it an ID :-
$ sudo dscl . -create /Groups/newgroup
$ sudo dscl . -create /Groups/newgroup PrimaryGroupID 1000
View the new group :-
$ dscl . -read /Groups/newgroup
AppleMetaNodeLocation: /Local/Default
GeneratedUID: 423AF02C-F053-41E0-ABCD-33127EF9A9CA
PrimaryGroupID: 1000
RecordName: newgroup
RecordType: dsRecTypeStandard:Groups
List existing user IDs in numerical order to choose an unused one for new user :-
$ dscl . -list /Users UniqueID | awk '{print $2}' | sort -n
Create the new user 'newuser' and assign various attributes :-
$ sudo dscl . -create /Users/newuser
$ sudo dscl . -create /Users/newuser UserShell /bin/bash
$ sudo dscl . -create /Users/newuser RealName "New User"
$ sudo dscl . -create /Users/newuser UniqueID "1000"
$ sudo dscl . -create /Users/newuser PrimaryGroupID 1000
View the new user :-
$ dscl . -read /Users/newuser
AppleMetaNodeLocation: /Local/Default
GeneratedUID: 47D6D841-C7F1-4962-9F7E-167E8BFC3A91
PrimaryGroupID: 1000
RealName:
 Application
RecordName: newuser
RecordType: dsRecTypeStandard:Users
UniqueID: 1000
UserShell: /usr/bash 
Add user to existing group :-
$ sudo dscl . -append /Groups/newgroup GroupMembership newuser
Change user password :-
$ sudo dscl . passwd /Users/newuser PASSWORD

Комментариев нет:

Отправить комментарий