Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to set up a git user, but am getting the error

useradd: cannot create directory /srv/data/git when running this command

sudo useradd                      \
  --create-home                   \
  --skel      /dev/null           \
  --home-dir  /srv/data/git       \
  --shell     /usr/bin/git-shell  \
  --comment   'Web Archive VCS'   \
git

Why am I having trouble? When creating the directory first, (mkdir -p /srv/data/git) I receive the following two errors/warnings.

useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.

This should be very straight forward, but is having issues for unknown reasons to me

share|improve this question
up vote 1 down vote accepted

It looks like useradd uses mkdir or something akin to if WITHOUT the -p flag, this means that the directory MUST exist up to the last portion of the path. This seems like a functionality gap.

In order to fix the above, I/you will need to mkdir -p /srv/data before running the switch for ... --create-dir --home-dir /src/data/git ...

share|improve this answer

You must log in to answer this question.

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