Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

See I have created some user in my CentOS with useradd command. And I didn't get any kind of automatic standard dir creation and its not been versatile actually while I am creating that user. see the log please.

root@localhost raja]# useradd positiveman
[root@localhost raja]# passwd positiveman
Changing password for user positiveman.
New password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost raja]# ls /home/august
[root@localhost raja]# ls /home/august/
[root@localhost raja]# cd /home/
[root@localhost home]# ls
august  positiveman  raja
[root@localhost home]# cd august/
[root@localhost august]# ls
[root@localhost august]# cd ..
[root@localhost home]# cd positiveman/
[root@localhost positiveman]# ls
[root@localhost positiveman]#

what might be the reason ?

share|improve this question
2  
if you expect things like this to be done for you by default, use adduser instead of useradd, if it's available. –  strugee Dec 29 '13 at 12:17

2 Answers 2

up vote 5 down vote accepted

You have to give some options to useradd to create the directory. You can find those in the man page:

-m, --create-home
       Create the user's home directory if it does not exist. The files
       and directories contained in the skeleton directory (which can be
       defined with the -k option) will be copied to the home directory.

       By default, if this option is not specified and CREATE_HOME is not
       enabled, no home directories are created.
share|improve this answer

useradd has largely been replaced by the newer adduser, as explained in man adduser:

   useradd is a low level utility for adding users. On Debian,
   administrators should usually use adduser(8) instead.

So, instead of using useradd, use adduser that will create everything for you automatically:

$ sudo adduser foo
Adding user `foo' ...
Adding new group `foo' (1007) ...
Adding new user `foo' (1007) with group `foo' ...
Creating home directory `/home/foo' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for foo
Enter the new value, or press ENTER for the default
    Full Name []: 
    Room Number []: 
    Work Phone []: 
    Home Phone []: 
    Other []: 
Is the information correct? [Y/n] 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.