LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-09-2010, 08:17 AM   #1
dwoelper
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Rep: Reputation: 0
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
 
Old 04-09-2010, 08:21 AM   #2
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by dwoelper View Post
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
 
Old 04-09-2010, 08:27 AM   #3
dwoelper
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 04-09-2010, 08:32 AM   #4
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by dwoelper View Post
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.

Last edited by Sayan Acharjee; 04-09-2010 at 08:33 AM.
 
Old 04-09-2010, 08:38 AM   #5
dwoelper
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 04-09-2010, 08:48 AM   #6
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by dwoelper View Post
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.

Last edited by Sayan Acharjee; 04-09-2010 at 08:53 AM.
 
Old 04-09-2010, 09:28 AM   #7
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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.
 
Old 04-09-2010, 09:52 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] 'Could not chdir to home directory /home/[user]: Permission denied' arashi256 Linux - Newbie 25 11-11-2011 10:29 AM
RHEL 5.2+LDAP Server+File already exists while creating directory in /home sharjeel Linux - Server 2 08-05-2009 11:05 PM
"Home directory already exists. Please enter another home directory path." Daravon Ubuntu 2 02-15-2009 11:26 PM
Adding and removing an application for a specific user the_transltr Linux - General 2 08-03-2008 09:49 PM
adding a new user doesn't create a home directory abrakadabra Linux - General 6 08-09-2002 09:11 PM


All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration