LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   adding a new user doesn't create a home directory (https://www.linuxquestions.org/questions/linux-general-1/adding-a-new-user-doesnt-create-a-home-directory-27572/)

abrakadabra 08-09-2002 12:11 PM

adding a new user doesn't create a home directory
 
It all started after I used the usermod command to modify the login for a user. User johnDo (fictitious for security reasons) was logged-in , I su - root to modify the login from johnDo to johnDoe using

#usermod -l johnDoe johnDo.

No problems so far. Then, for consistency reasons, I went ahead and modified the user's home directory from /home/johnDo to /home/johnDoe. I exited out of the root session, logged out as johnDo and logged back in. Then, I found out that to perform this operation one needs to be LOGGED-OUT from the user to be modified, or the system "gets confused", too late for this!. From then on every time I create a user, all the records are fine in the passwd file. My useradd -D are correct but the home directory for any user I'm adding does not get created. I hope that someone can post some ideas as to where to begin to triage this.

Thanks in advance.

:confused:

MartBrooks 08-09-2002 12:17 PM

mkdir /home/<username>
chown <username>.<usergroup> /home/<username>

Regards

abrakadabra 08-09-2002 01:15 PM

Hi MartBrooks,

That is what I did as a workaround to get the user going and it's working fine. But my problem is that for every new user I create I have the same problem, and need to do this process again to create their directory, change owners, etc...
This wasn't happening before.....

Thanks.

realos 08-09-2002 05:00 PM

please look in the file /etc/defaults/useradd there you can give the defaults if and where, for expample, home directory should be created etc....

can you give the output of the file and what distro you are using?...


regards

pk21 08-09-2002 05:05 PM

If you cant find a solution then just build a script and give it an alias.
This will speed up the whole process.

realos 08-09-2002 05:23 PM

hi,

my mistake in the last posting ...

read the man pages of useradd and you will see that by default there is no directory created. you should add the option -m to the command-->> useradd -m newuser and you will be fine,

take care

abrakadabra 08-09-2002 08:11 PM

Hi realos,

thanks for the input. I looked at the man pages for useradd did some testing using the -m flag and the directories are getting created. I still think that something happened when I used usermod logged in as the user to be modified. Actually when a user is added and no flags are passed to the useradd command, the defaults in useradd -D are created in my case is:
GROUP=100
HOME=/home
INACTIVE=0
EXPIRE=10000
SHELL=/bin/bash
SKEL=/etc/skel
I tested useradd on other machines same version ( SuSE 7.2) and the user's home directory are created by default just fine.
e.g

# useradd testing

if I su - testing
then cd
then pwd

I get .....

/home/testing

notice I did not specified -m

any way in the broken PC using -m works fine. From here I'd like to figure out what might've got broken.

pk21 thanks for the idea of creating a script I'm sure this can be a good resource when things get really bad.

Anyway thank you both for the input.


All times are GMT -5. The time now is 07:45 PM.