Users can be added to a linux machine either by creating manually or by syncing with an external authentication system such as LDAP. If you are creating users manually, the user home directories will be automatically created. But if you are syncing with an LDAP, the home directories will not be created automatically by default. If you are going to create all the home directories manually, it will be a tedious job, because in most of the cases, there will be hundreds of users. There are some methods to enable auto creation of user home directories.
One method is by using pam_mkhomedir.so. Another method is using oddjob. The method I am gonna discuss here is using oddjob. It is very easy to enable this feature. My operating system is CentOS 6.4. This solution will work with Redhat and CentOS operating systems.
First install oddjob and oddjob-mkhomedir packages.
yum install oddjob oddjob-mkhomedir
Then start the oddjob service. Make this daemon to start automatically on startup.
chkconfig oddjobd on service oddjobd start
After this we have to update to our authentication mechanism to instruct oddjob to create the user home directories automatically.
authconfig --enablemkhomedir --update
Now we are ready. The user home directories will be created automatically on login.