- #How to add a user account to mac os mac os x#
- #How to add a user account to mac os code#
- #How to add a user account to mac os password#
- #How to add a user account to mac os free#
I also needed cleanup code so you don't wind up with users left in the database after they have been removed. I had to add a lot of logic to search the Netinfo database for duplications. I'm not sure if using the tools with OSX Server solve either of these issues, but we don't run a server so it was not important for me to know anyway.Īnother thing to consider about command line management of user accounts is the add/remove process for groups. My script uses CpMac (part of Dev tools) to overcome this shortcoming.Īpple's GUI does not allow you to specify a UID or alternate home directory. If you need to customize your builds like we do, this can be a deal breaker. Some things to consider about advantages of this method for adding user accounts.Īpple's GUI does not preserve resource forks when populating the home directory. In general this becomes a much more complicated process than it would first appear. It has some elements that are specific to my organization. I have been refining my adduser script for many months.
Optionally you could SSH to another machine and create accounts. sudo cp -R /System/Library/User\ Template/English.lproj /Users/ftpusersudo chown -R ftpuser:staff /Users/ftpuserThis is basically what happens when you use the Accounts Preference Pane to create an account. This will create the standard set of directories and files for the new user.
#How to add a user account to mac os mac os x#
You could simply create the directory and give the user ownership of it, or use the lines below to copy the standard Mac OS X user template. The last step is to create the user's home directory.
#How to add a user account to mac os password#
Optionally you can skip this step, and the account is created, but logins are disabled until the password has a value assigned. sudo niutil -create / /users/ftpusersudo niutil -createprop / /users/ftpuser uid 555sudo niutil -createprop / /users/ftpuser realname "FTP User"sudo niutil -createprop / /users/ftpuser home "/Users/ftpuser"sudo niutil -createprop / /users/ftpuser shell "/dev/null"sudo niutil -createprop / /users/ftpuser gid 20sudo niutil -createprop / /users/ftpuser passwd "*" sudo passwd ftpuserThen you will be prompted to enter the password you want to create for the new user. There are other properties you can assign a user, but these are the basic ones that you should use. By assigning the /dev/null shell, we are preventing the user from logging in via SSH. The home directory can really be anywhere, but we are using the standard location in this example. Remember you can't reuse a shortname, so if there is already a user called "ftpuser", you need to pick something else.
#How to add a user account to mac os free#
Feel free to substitute the shortname of your choice.
The user I am creating here has a shortname of "ftpuser". The first line here will create the user, but then you need to assign it some properties. You will use it in place of the uid 555 below. User accounts generally start at 501, and work up, so look at the list returned, and pick the next available number to assign to the new user you are creating. Open the terminal and type: nireport / /users name uid | grep "5"This should report all users that are in the 500+ range for the user ID. First you need to know the current users, and their user IDs. Regards.Here are the steps required to create a user in the terminal on a Mac OS X machine. Hopefully, I can get enough points to post the answer or, someone can unprotect this question. Probably not very secure, but it's the best work-around we've come up with to allow tests to run without requiring user intervention. Tell application "SecurityAgent" to activate If "SecurityAgent" is in ProcessList then # Determine if authentication is being requested # Delay for 10 seconds as this script runs asynchronously to the automation process and is kicked off first. The script below should be executed asynchronously prior to launching your automated test: osascript & (The first one is actually closed and I disagree with the localization reasoning.)Īnyway, we created a work-around using AppleScript that folks may be interested in.