Unable to create user home directory on Mac OS while creating user from terminal

Hi Everyone,

we have one Mac Instance on EC2, I am trying to create one admin user through terminal, I used below command to create, but home directory is not creating and I am unable to switch the user by using SU command.


sudo dscl . -create /Users/luser

sudo dscl . -create /Users/luser UserShell /bin/bash

sudo dscl . -create /Users/luser RealName "Lucius Q. User"

sudo dscl . -create /Users/luser UniqueID "1010"

sudo dscl . -create /Users/luser PrimaryGroupID 80

sudo dscl . -create /Users/luser NFSHomeDirectory /Users/luser

sudo dscl . -append /Groups/admin GroupMembership luser

Posted on Feb 11, 2022 3:46 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 11, 2022 8:13 PM

That creates the user in the OpenLDAP subsystem but it doesn't create the home directory that is an additional step using different tools or by hand.


createhomedir
-h displays this help info
-s create home directories for server home paths only (default)
-c create home directories for local home paths only
-b create home directories for both server and local home paths
-a traverse search node and create local user home directories
-l traverse local node and create local user home directories
-L cause the created home directory to be localized
-n nodename traverse specified node and create local user home directories
-u username traverse search node and create specified local user home directory
-i read username list from standard input and create specified home directories


You can also create users with sysadminctl command:


Usage: sysadminctl
	-deleteUser <user name> [-secure || -keepHome] (interactive || -adminUser <administrator user name> -adminPassword <administrator password>)
	-newPassword <new password> -oldPassword <old password> [-passwordHint <password hint>]
	-resetPasswordFor <local user name> -newPassword <new password> [-passwordHint <password hint>] (interactive] || -adminUser <administrator user name> -adminPassword <administrator password>)
	-addUser <user name> [-fullName <full name>] [-UID <user ID>] [-GID <group ID>] [-shell <path to shell>] [-password <user password>] [-hint <user hint>] [-home <full path to home>] [-admin] [-roleAccount] [-picture <full path to user image>] (interactive] || -adminUser <administrator user name> -adminPassword <administrator password>)
	-secureTokenStatus <user name>
	-secureTokenOn <user name> -password <password> (interactive || -adminUser <administrator user name> -adminPassword <administrator password>)
	-secureTokenOff <user name> -password <password> (interactive || -adminUser <administrator user name> -adminPassword <administrator password>)
	-guestAccount <on || off || status>
	-afpGuestAccess <on || off || status>
	-smbGuestAccess <on || off || status>
	-automaticTime <on || off || status>
	-filesystem status
	-screenLock <status || immediate || off || seconds> -password <password>

Pass '-' instead of password in commands above to request prompt.
'-adminPassword' used mostly for scripted operation. Use '-' or 'interactive' to get the authentication string interactively. This preferred for security reasons

	*Role accounts require name starting with _ and UID in 200-400 range.


1 reply
Question marked as Top-ranking reply

Feb 11, 2022 8:13 PM in response to Atul_Jaiswal

That creates the user in the OpenLDAP subsystem but it doesn't create the home directory that is an additional step using different tools or by hand.


createhomedir
-h displays this help info
-s create home directories for server home paths only (default)
-c create home directories for local home paths only
-b create home directories for both server and local home paths
-a traverse search node and create local user home directories
-l traverse local node and create local user home directories
-L cause the created home directory to be localized
-n nodename traverse specified node and create local user home directories
-u username traverse search node and create specified local user home directory
-i read username list from standard input and create specified home directories


You can also create users with sysadminctl command:


Usage: sysadminctl
	-deleteUser <user name> [-secure || -keepHome] (interactive || -adminUser <administrator user name> -adminPassword <administrator password>)
	-newPassword <new password> -oldPassword <old password> [-passwordHint <password hint>]
	-resetPasswordFor <local user name> -newPassword <new password> [-passwordHint <password hint>] (interactive] || -adminUser <administrator user name> -adminPassword <administrator password>)
	-addUser <user name> [-fullName <full name>] [-UID <user ID>] [-GID <group ID>] [-shell <path to shell>] [-password <user password>] [-hint <user hint>] [-home <full path to home>] [-admin] [-roleAccount] [-picture <full path to user image>] (interactive] || -adminUser <administrator user name> -adminPassword <administrator password>)
	-secureTokenStatus <user name>
	-secureTokenOn <user name> -password <password> (interactive || -adminUser <administrator user name> -adminPassword <administrator password>)
	-secureTokenOff <user name> -password <password> (interactive || -adminUser <administrator user name> -adminPassword <administrator password>)
	-guestAccount <on || off || status>
	-afpGuestAccess <on || off || status>
	-smbGuestAccess <on || off || status>
	-automaticTime <on || off || status>
	-filesystem status
	-screenLock <status || immediate || off || seconds> -password <password>

Pass '-' instead of password in commands above to request prompt.
'-adminPassword' used mostly for scripted operation. Use '-' or 'interactive' to get the authentication string interactively. This preferred for security reasons

	*Role accounts require name starting with _ and UID in 200-400 range.


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Unable to create user home directory on Mac OS while creating user from terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.