how to change a user home directory to adirectory that already exits?

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.

1

1 Answer

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

Ex. given

$ getent passwd testuser
testuser:x:1001:1001:,,,,:/home/testuser:/bin/sh

then

$ 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
testuser:x:1001:1001:,,,,:/home/foo:/bin/sh

And just to be sure:

$ su - testuser
Password:
$ pwd
/home/foo

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like