8. Automatic home directory creation [optional]

When a user logs into a system for the first time, their directory may not exist. If you want the system to automatically create the user's home directory upon first login, you can use the pam_mkhomedir.so PAM (Pluggable Authentication Modules for Linux). This not only creates the user's home directory, but also populates the directory with important files (.bashrc, etc), changes the ownership, and sets the home directory permissions. As "root", the following command will append the pam_mkhomedir.so options to your /etc/pam.d/common-session.

echo "session optional pam_mkhomedir.so" >> /etc/pam.d/common-session

Last updated