Execute Commands on User Login

In addition to the normal I wanted to create a directory for each user on an alternative disk. To do so I edited:

vi /etc/pam.d/password-auth

added the line below (just above the line: session optional

session     optional /usr/local/bin/

Then created the file:

vi /usr/local/bin/

and added the following:

if [ ! -d /local/$PAM_USER ]; then
mkdir /local/$PAM_USER
chown $PAM_USER:ldapusers /local/$PAM_USER
chmod +x /usr/local/bin/

It is also possible to add extra options to (man pam_exec) for debugging e.g.

session     optional debug log=/tmp/pam_exec.log /usr/local/bin/


Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>