I have a website user who I want to be able to upload content to a folder on my server. I thought ok, I'll create a new user, and change his home directory to the folder where his stuff is already.

No such luck, usermod wont allow me to create that directory, it already exists.

$ sudo usermod -m -d /public_html/user user
  usermod: directory /public_html/user exists

I looked through the man page but did not see an immediate solution to this problem.

  • Ehm, sorry but no. Just no. The horror stories I can tell where a windows admin decides to open /home/ as share where the user shift-deletes the files starting with a dot. Users need to be in /home and outside a webserver. You should create a symlink in /home/$USER/, force the user into that folder and connect that to /public_html/user – Rinzwind Jul 27 '18 at 14:30

The message is only informational - the change should be accepted regardless.

Ex. given

$ getent passwd testuser


$ sudo mkdir /home/foo 
$ sudo usermod -m -d /home/foo testuser
usermod: directory /home/foo exists

however the home directory was successfully changed

$ getent passwd testuser

And just to be sure:

$ su - testuser
$ pwd

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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