Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

A script that requires root privileges needs to be executed when a non-root privileged user signs in/out. How do I handle this?

share|improve this question

1 Answer 1

Use the PAM session hooks module.

share|improve this answer
Thats useful. Now, some of operations in which I want to apply should be done before the memory is allocated for user account. And, the operations need to be done after the user account memory is fully deallocated. When does PAM actually trigger the scripts in concern with user account memory allocation/deallocation? One operation I intend to run is sdmem, which cleans the available ram. I need users who sign out to be cleaned up this way. –  bambuntu Feb 7 '12 at 1:18
Linux doesn't allocate memory "for a user account" or at login time. Memory is allocated as new processes start. If you run this script from pam hooks, it will start before the user is able to run any programs. –  poolie Feb 7 '12 at 1:59
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Mitch Jul 8 '13 at 11:23

Your Answer


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.