Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.