LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help! Adding user with a specific home directory that already exists (https://www.linuxquestions.org/questions/linux-newbie-8/help-adding-user-with-a-specific-home-directory-that-already-exists-801011/)

dwoelper 04-09-2010 07:17 AM

Help! Adding user with a specific home directory that already exists
 
Hey everyone,

Im trying to add users to my nfs server with a specific home directory that already exists. Can this be done? I've done some research on google and other forums but cant seem to find the answer. Maybe I'm searching the wrong question, im not sure, anyway any help would be great!

Thanks, Dave

Sayan Acharjee 04-09-2010 07:21 AM

Quote:

Originally Posted by dwoelper (Post 3929800)
Hey everyone,

Im trying to add users to my nfs server with a specific home directory that already exists. Can this be done? I've done some research on google and other forums but cant seem to find the answer. Maybe I'm searching the wrong question, im not sure, anyway any help would be great!

Thanks, Dave

Use the following command:

Quote:

#useradd -d location_of_the_home_directory username

dwoelper 04-09-2010 07:27 AM

i get the following errors:

Code:

[root@MRB home]# useradd -d /mnt/sdb/home/10aielmi/ 10aielmi
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists
[root@MRB home]# su 10aielmi
bash: /mnt/sdb/home/10aielmi//.bashrc: Permission denied


Sayan Acharjee 04-09-2010 07:32 AM

Quote:

Originally Posted by dwoelper (Post 3929812)
i get the following errors:

Code:

[root@MRB home]# useradd -d /mnt/sdb/home/10aielmi/ 10aielmi
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists
[root@MRB home]# su 10aielmi
bash: /mnt/sdb/home/10aielmi//.bashrc: Permission denied


Can you please check if that home directory is already in use by some other user? Or may be the user already exists, check the /etc/passwd file to be sure.

dwoelper 04-09-2010 07:38 AM

i know that they are not in use. heres whats goin on: i backed up the home directory to a hard drive before i reinstalled. i upgraded to fc12 and hooked that backup drive with home on it as a slave drive. i set that drive to be mounted to /mnt/sdb. the path of the home directory is /mnt/sdb/home.
there is about 30 users in the home directory i need to make an account for that all need to use those directories. Maybe something inside of the user home directories needs to be removed. i dont know.

Sayan Acharjee 04-09-2010 07:48 AM

Quote:

Originally Posted by dwoelper (Post 3929829)
i know that they are not in use. heres whats goin on: i backed up the home directory to a hard drive before i reinstalled. i upgraded to fc12 and hooked that backup drive with home on it as a slave drive. i set that drive to be mounted to /mnt/sdb. the path of the home directory is /mnt/sdb/home.
there is about 30 users in the home directory i need to make an account for that all need to use those directories. Maybe something inside of the user home directories needs to be removed. i dont know.

Ok, now I know why its giving that weird error. When you are trying to add a new user with that directory as home directory its trying to copy the necessary files from /etc/skel to that directory and as these files are already there its resulting that error.

Create a user first then change its home directory by editing the /etc/passwd file, see if it works.

evo2 04-09-2010 08:28 AM

Instead of using adduser you can use useradd which will not try to create the home dir or copy the skel files.
Read the man page for details.

Cheers,

Evo2.

catkin 04-09-2010 08:52 AM

Regards
Code:

[root@MRB home]# su 10aielmi
bash: /mnt/sdb/home/10aielmi//.bashrc: Permission denied

You need to give the user not only the same name as the old one but the same user ID, too. That's the number in the 3rd field of the /etc/passwd line for the user. Or you could chown the files.

If it was my personal system (where I don't mind breakage to learn things) I'd copy the lines for those 30 users from the old passwd and shadow files to the new one ... take care (make sure you can always get back to where you started).

You might have similar issues with group names/numbers. Useful to create any new groups with same numbers as old system if copying files from old system.


All times are GMT -5. The time now is 05:07 AM.