Linux – How to linux auto-create directories for a user at the first login

linux

I have setup pam_mkhomedir so that users home directories are automatically created at their first login. But I also want to create directories on a different place like this.

  • /home/username (pam_mkhomedir can make this directory)
  • /scratch/username

As far as I know, having a script in /etc/profile.d can't manage this because normal users don't have write-permission on /scratch.

Does anyone know how to make this happen?

Thanks in advance.

Best Answer

You can use pam_exec to trigger a script at login. In the script you can create the /scratch/username folder if it does not exist.