{"id":1407,"date":"2010-03-31T11:44:49","date_gmt":"2010-03-31T03:44:49","guid":{"rendered":"http:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/?p=1407"},"modified":"2010-03-31T11:44:49","modified_gmt":"2010-03-31T03:44:49","slug":"how-to-add-a-user-from-the-os-x-command-line","status":"publish","type":"post","link":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/?p=1407","title":{"rendered":"How to: Add a user from the OS X command line"},"content":{"rendered":"<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create a new entry in the local (\/) domain under the category \/users.<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -create \/Users\/toddharris<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create and set the shell property to bash.<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -create \/Users\/toddharris UserShell \/bin\/bash<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create and set the user\u2019s full name.<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -create \/Users\/toddharris RealName \"Dr. Todd Harris\"<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create and set the user\u2019s ID.<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -create \/Users\/toddharris UniqueID 503<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create and set the user\u2019s group ID property.<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -create \/Users\/toddharris PrimaryGroupID 1000<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create and set the user home directory.<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -create \/Users\/toddharris NFSHomeDirectory \/Local\/Users\/toddharris<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Set the password.<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -passwd \/Users\/toddharris PASSWORD<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">or<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\"><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">passwd toddharris<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">If you would like Dr. Harris to be able to perform administrative functions:<br style=\"padding: 0px; margin: 0px;\" \/><code style=\"background-color: #f1f1f1; font-size: 1.2em; padding: 3px; margin: 0px; border: 1px solid #cccccc;\">dscl \/ -append \/Groups\/admin GroupMembership toddharris<\/code><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Read informations about a group, e.g. &#8220;_developer&#8221;<\/p>\n<p><span style=\"font-family: 'Courier New', Courier, monospace;\">dscl localhost -read \/Local\/Default\/Groups\/_developer<\/span><\/p>\n<p>or shorter<\/p>\n<p><span style=\"font-family: 'Courier New', Courier, monospace;\">dscl . -read \/Groups\/_developer<\/span><\/p>\n<p>If you want to know the groups your user is a member of<\/p>\n<p><span style=\"font-family: 'Courier New', Courier, monospace;\">id -Gn<\/span><\/p>\n<p>Add the user &#8220;gustav&#8221; to the group &#8220;_developer&#8221;<\/p>\n<p><span style=\"font-family: 'Courier New', Courier, monospace;\">sudo dscl . -append \/Groups\/_developer GroupMembership gustav<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create a new entry in the local (\/) domain under the category \/users.dscl \/ -create \/Users\/toddharris<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding: 0px;\">Create and set the shell property to bash.dscl \/ -create \/Users\/toddharris UserShell \/bin\/bash<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: [...] \n\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[3],"tags":[9],"class_list":["post-1407","post","type-post","status-publish","format-standard","hentry","category-computer","tag-mac","odd"],"_links":{"self":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1407"}],"version-history":[{"count":1,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1407\/revisions"}],"predecessor-version":[{"id":1408,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1407\/revisions\/1408"}],"wp:attachment":[{"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staff.ie.cuhk.edu.hk\/~sfluk\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}