I want to create a user to run tomcat on my system and was wondering if it is possible to create a user without a home directory like it is possible in linux.

1 Answer 1


Yes you can, using the following code. Note that the UniqueID, if less than 501, may not list the user in the Accounts pane of system preferences, depending upon the OS version. Be careful that it is not already assigned to another user account.

sudo dscl . -create /Users/ThisUserName
sudo dscl . -create /Users/ThisUserName UserShell /bin/bash
sudo dscl . -create /Users/ThisUserName UniqueID 505
sudo dscl . -create /Users/ThisUserName PrimaryGroupID 20
sudo dscl . -passwd /Users/ThisUserName Pa55w0rd

You can assign a home folder outside of the normal /Users/ hierarchy with:

sudo dscl . -create /Users/ThisUserName NFSHomeDirectory /path/to/your/home

If you want a clearer name to show up in the accounts preference:

sudo dscl . -create /Users/ThisUserName RealName "This User Name"

If you su to the new user without having set a NFSHomeDirectory, the $HOME defaults to /var/empty.

  • 2
    If you want to create an account to run tomcat, I'd suggest not to give it a password, a shell of /usr/bin/false, to give it an ID = 80 (below 500), and a name of _tomcat (to follow the rules on MacOS X).
    – dan
    Jul 18, 2013 at 16:34
  • @danielAzuelos using /bin/false as the home directory prevents me from su-ing to the user.
    – Dark Star1
    Jul 22, 2013 at 8:34
  • 1
    → Dark: I suggested do give it a shell of /usr/bin/false not a home. This is the standard way all _users are configured on MacOS X. This doesn't prohibit any access through sudo. Check with: dscl & sudo on _sandbox.
    – dan
    Jul 22, 2013 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .