0

[MacOS Catalina 10.15.6]

I've created a new user on a remove machine via ssh. The new user is able to log in, but their home folder contains no template files (bash profile) or folders. When adding users via the GUI, these folders are automatically generated.

I created the account using:

    sudo dscl . -create /Users/username
    sudo dscl . -create /Users/username UserShell /bin/bash
    sudo dscl . -create /Users/username RealName "John Smith"
    sudo dscl . -create /Users/username UniqueID ###
    sudo dscl . -create /Users/username PrimaryGroupID ##
    sudo dscl . -create /Users/username NFSHomeDirectory /Users/username
    sudo dscl . -passwd /Users/username password

With the new user logged out, I tried using sudo /usr/sbin/createhomedir -c -u <userName> but nothing was added.

How can this be done?

6
  • This sequence worked for me in 10.15.6. Did you log in as the new user in between the dscl commands and running createhomedir? If so, it probably created a mostly-empty home directory at login, and then createhomedir saw that /Users/username existed (even though it wasn't all there), and figured it didn't need creating. You might have to delete the directory, then run createhomedir again. BTW, the default user template doesn't include a bash profile (or even a zsh profile, which is the default user shell in 10.15). – Gordon Davisson Aug 22 '20 at 18:57
  • 1
    BTW2 for anyone copying this: the double-quotes around the RealName value need to be plain ASCII quotes, not fancy unicode curly quotes. That is, use "John Smith" instead of “John Smith”. Also, the PrimaryGroupID should almost always be 20 (the "staff" group); you can add additional groups (e.g. admin) with dseditgroup. – Gordon Davisson Aug 22 '20 at 18:58
  • @GordonDavisson: Thanks for your comments. Yes I did log in in-between, to check that the first series worked. I'll try again after deleting the folder. I also fixed the double quotes around the user's real name. – gone Aug 23 '20 at 5:09
  • After I posted this question, I had the actual user log in (which was a few hours after I did this). When I returned just now to check the comments @GordonDavisson made, I found that the .ssh, Downloads, and Library folders had been created (and I know the other user didn't do that). So somewhere in between they were created. (Perhaps you could formulate your comments into an answer and I'll mark it?) – gone Aug 23 '20 at 5:14
  • I don't think I can claim an answer, since I'm not sure I understand what happened. But I may be able to clarify a little: directories like Library and Downloads tend to get auto-created even without the template, because many programs that store files in them will auto-create the folders if they don't exist. Actually, I think the Finder itself will auto-create ~/Library/Preferences (and hence ~ and ~/Library) because it needs it to store its preferences in. – Gordon Davisson Aug 23 '20 at 7:17

You must log in to answer this question.

Browse other questions tagged .