cannot create a user account on mac using command line I followed the instructions here to create the user jira:

sudo dscl . create /Users/jira 
sudo dscl . passwd /Users/jira
sudo dscl . create /Users/jira RealName "jira user"
sudo dscl . create /Users/jira UserShell /bin/bash
sudo dscl . append /Groups/admin GroupMembership jira


but I got two problems:

first the user appears as not an admin member although I have added them as an admin (and I have rebooted, see here)

second I cannot make this user own their directory, ie when I run

sudo chown jira /var/jira


I get

chown: jira: illegal user name


I cannot login as that user either:

su jira
Password:
su: unknown login: jira


although the jira user appears on the list of users:

dscl . list /Users | grep jira
jira


and
The instructions you're following are rather confused and incomplete; see this ServerFault question for better info. I think the main problem is that you haven't set all of the necessary attributes for the new user (although you've set more than your code fragment suggests!). You're missing:

sudo dscl . create /Users/jira UniqueID 499   # Use some unique user ID number here; numbers below 500 for hidden accounts
sudo dscl . create /Users/jira PrimaryGroupID 20   # This is the "staff" group; add to admins separately
sudo dscl . create /Users/jira NFSHomeDirectory /var/jira   # /var is a good place to hide things; regular users go under /Users
sudo dseditgroup -o edit -t user -a jira admin   # This is the RIGHT way to add a secondary group membership


The problems with your current setup are: the primary group membership of -2 (the "nobody" group), the confusion about whether the home directory is /Users/jira or /var/jira (make sure the NFSHomeDirectory points to the actual location! of the directory!), and that you aren't fully setting the membership in the admin group (appending the user's account name to GroupMembership is only part of it; you should also append their GeneratedUID to GroupMembers, or use dseditgroup and let it handle the details).

EDIT: Kent made a good point that /Users/jira is always the path to the users account in dscl, and might also be the path to the user's home folder in the file system (the NFSHomeDirectory attribute). They're confusingly similar, but don't necessarily have anything to do with each other. In the commands above, I show setting the home folder location to /var/jira instead to hide it. So, to make my example complete, here's how you'd create the home folder:

cp -R /System/Library/User\ Template/English.lproj /var/jira
chown -R jira:staff /var/jira


These commands create the home folder; the NFSHomeDirectory attribute tells the user where to find it when they log in. It's important that they match.

Oh, and if English isn't the user's primary language, there are a bunch of other user templates to choose from.