LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-07-2010, 10:53 AM   #1
swissrunner
LQ Newbie
 
Registered: Apr 2009
Posts: 13

Rep: Reputation: 0
useradd creates user but fails to make home directory


Hi all,

when I try to add a user it fails to make the corresponding home directory. I can still su to the user, set the password, and everything else.
the output is as follows:

$ useradd username
useradd: cannot create home directory /home/username

I read that this could be a result of there not being enough space but if I do df -h, i see that only 88% of the memory is being used.

All help is appreciated,

Xenia
 
Old 10-07-2010, 10:54 AM   #2
czarherr
Member
 
Registered: Sep 2003
Location: Suwon, Korea
Distribution: Slackware 14
Posts: 288

Rep: Reputation: 32
"useradd -m username" will create a home directory. By default, useradd alone will not. Add -k to add files from your skeleton directory. This is all in the man page.

Last edited by czarherr; 10-07-2010 at 10:58 AM.
 
Old 10-07-2010, 11:04 AM   #3
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
What is your distro? Try turning off autofs and see if it works.
 
Old 10-07-2010, 11:14 AM   #4
btncix
Member
 
Registered: Aug 2009
Location: USA
Posts: 141

Rep: Reputation: 26
Personally, learning to use useradd is a good thing because it helps you better learn how to add users to your system, but I tend to get lazy with certain things such as adding a user so I use adduser instead.

If you want to try adduser, either create a new user with a different name or first delete the original user you created with userdel. See the man pages for details.
 
Old 10-07-2010, 11:15 AM   #5
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
Hi,

Which Linux Distribution,you are using?

Hope you are trying to create the user with root.

also try

useradd -d /home/user1 user1

In some distributions you need to create home directory manually and specify that in useradd command.
 
Old 10-07-2010, 12:09 PM   #6
raviteja_s
Member
 
Registered: Jun 2010
Location: India
Distribution: Redhat
Posts: 68

Rep: Reputation: 1
Check this file !

;> vim /etc/default/useradd

# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
 
Old 10-07-2010, 02:57 PM   #7
basheer
Member
 
Registered: Mar 2009
Location: Bangalore, India
Distribution: CentOS6.5, CentOS7, Ubuntu14.04
Posts: 182

Rep: Reputation: 29
hi do the following
#groupadd youruser
#useradd -g youruser -s /bin/bash -m -k /dev/null youruser
It will create a home directory, set the default shell to bash, point the skeleton to /dev/null, set userid and groupid to the same id.



or simply use
#adduser youruser

Hope it solves your problem.

Last edited by basheer; 10-07-2010 at 02:58 PM.
 
Old 10-08-2010, 10:09 AM   #8
swissrunner
LQ Newbie
 
Registered: Apr 2009
Posts: 13

Original Poster
Rep: Reputation: 0
Hi guys thank you for all the input!

I am running all the commands as root. My distro is centos 5.0
all of the below gave me the same error as before, "unable to create home directory /home/username"

# adduser username

#groupadd youruser
#useradd -g youruser -s /bin/bash -m -k /dev/null youruser

#useradd -d /home/user1 user

#useradd -m username

i looked at /etc/default/useradd
and it looked just like the example you gave me raviteja_s


I'm not sure how to turn off autof can you please help me out a bit on that one. Also, are there any other ideas?
Thank you all very much!
 
Old 10-08-2010, 10:40 AM   #9
hurryi
Member
 
Registered: Apr 2010
Distribution: RHEL
Posts: 77

Rep: Reputation: 7
hello,

you can set in /etc/login.defs

change the value from no to yes
CREATE_HOME yes

but with -m it should work, maybe a stupid thing but what if your partition mounted in readonly?
please check/give the output of "mount" command
 
Old 10-08-2010, 10:56 AM   #10
swissrunner
LQ Newbie
 
Registered: Apr 2009
Posts: 13

Original Poster
Rep: Reputation: 0
Hi,

Thank you
the output from mount as well as from doing ls -ls on the /home directory shows that root has read,write, and execute privileges.

also /etc/login.defs has the default already at yes.
 
Old 10-08-2010, 11:18 AM   #11
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
is autofs running?

service autofs status
service autofs stop

chkconfig autofs off
or
edit /etc/auto.master or /etc/auto.misc to not automount home directories.

If autofs is automounting home directories then it will not allow directory creation in /home

Last edited by frndrfoe; 10-08-2010 at 11:22 AM.
 
Old 10-08-2010, 03:35 PM   #12
swissrunner
LQ Newbie
 
Registered: Apr 2009
Posts: 13

Original Poster
Rep: Reputation: 0
hi,

Thank you for your idea, but autofs is not running,

$ service autofs status
automount is stopped
 
Old 10-08-2010, 03:42 PM   #13
jcmlq
Member
 
Registered: Aug 2009
Posts: 32

Rep: Reputation: 19
What happens if you mkdir /home/username manually?
 
Old 10-15-2010, 01:12 PM   #14
swissrunner
LQ Newbie
 
Registered: Apr 2009
Posts: 13

Original Poster
Rep: Reputation: 0
I get the same error, "unable to create directory." Even running that command as root.
 
Old 10-16-2010, 09:05 PM   #15
frndrfoe
Member
 
Registered: Jan 2008
Distribution: RHEL, CentOS, Ubuntu
Posts: 379

Rep: Reputation: 38
I would install strace if it is not already there and run 'strace mkdir /home/foo'
then post the output here and maybe one of us can spot something.
 
  


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
useradd: cannot create directory /home/ amirzkria Red Hat 5 08-07-2014 10:11 AM
[SOLVED] useradd not creating home directory magnusprime Solaris / OpenSolaris 7 01-27-2010 06:08 PM
Make FTP user and specify directory outside home mirror51 Linux - Newbie 4 09-21-2009 01:19 AM
[SOLVED] useradd and the home directory. stf92 Linux - Newbie 7 09-16-2009 09:42 AM
useradd - No home directory is created ]SK[ Linux - Newbie 16 07-14-2008 02:35 PM


All times are GMT -5. The time now is 08:25 AM.

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