Add a user with an already existing home directory
Solution 1:
I solved it by the following:
# adduser --home /home/bob bob
# chown -R bob:bob /home/bob
Since the new user does not automatically own the old home directory, they are initially unable to login. So I had to use the second line.
Finally, there are still some glitches in the new account. I assume I will have to clear all of the cache and config files from the old home directory (~/.config
, ~/.cache
, and ~/.local/share
it seems).
Solution 2:
adduser bob --no-create-home --home /home/bob/ --uid [the_uid]
--help
gives you all the possible flags you can use.
Solution 3:
For those who use useradd
as a habit, try this:
sudo useradd -s [your_shell_of_choice] -d /home/bob -M bob
sudo chown -R bob:bob /home/bob
-
-d
is equivalent to--home
-
-M
is equivalent to--no-create-home
-
-s
is usually followed by/bin/bash
, but it's your choice
See also: useradd --help
. Actually, you'll find it to be similar to adduser
.