LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I transfer users after upgrade? (http://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-transfer-users-after-upgrade-655092/)

jlietzow 07-11-2008 08:35 AM

How do I transfer users after upgrade?
 
I have what I hope is a simple question about recreating users through an upgrade on a PC I use at home. I upgraded from Linux Mint 4 to 5 last night on a PC at home, which has 3 users (me and my 2 kids).

Because I have a habit of trying new distributions, I created a separate partition for /home the last time I did an install (Mint 4). When I installed Mint 5 last night I "manually" partitioned the disk and told the installer to mount that partition as /home. Happily it behaved as I had hoped. I got the new distro installed cleanly but preserved all of the home directories. The user account created on install for me must have been assigned the same uid, as it is properly associated with my old home directory.

The only stumbling block I have now is that as I try to recreate users for my kids with the same names, the user admin tool (via the Gnome gui) complains that that home directory already exists and won't let me create the userid. I'd prefer to create the userid and point it to the pre-existing home directory. Any suggestions on how to do this? Is this just a limitation of the gui interface that I can get around by using the cli? Or perhaps I need to edit /etc/passwd directly.

I can see in hindsight that I should have preserved /etc/passwd, and maybe /etc/shadow and some other files. Any suggestions on a better way to do this in the future would also be appreciated.

b0uncer 07-11-2008 09:58 AM

Just use useradd (or adduser), and see it's command line parameters before going on. The graphical tools might by default want to create a home directory, but with useradd the default option is not to create a home directory; to do that, you'll simply add another switch, and without it it won't create the dir (uses existing).

See
Code:

man useradd
or
Code:

useradd --help
which should provide the necessary help. Basically you just run (as root or with sudo)
Code:

useradd -d /home/username -s /bin/bash username
to create user "username" with home directory "/home/username" (that exists already; if not, use -m switch to create it). You should specify the shell with -s even though you're not forced to, because if you don't, some apps might work in an unexpected manner (if they rely on the shell being set). And add extra options when necessary.

Hope it helps!

EDIT: if it happens that the newly created users have a UID set that differs from their home directory owner IDs, meaning basically that the new users don't own their home directories even though the usernames do match, you might want to run chown over the home directories (recursively) to make sure the users own their own homedirectories. Like this (as root or with sudo):
Code:

chown -R username /home/username
That makes "username" the owner of "/home/username", and if you specify -R as above, does it recursively (so that all files and subdirectories under /home/username are also affected).

jlietzow 07-12-2008 06:58 AM

Thanks!
 
Thanks much for the guidance. That worked perfectly. I did indeed need to chown the directories (didn't know about the -R option before) and that did the trick.

Thanks again!


All times are GMT -5. The time now is 06:42 AM.