How to get a notification when other users login into "my" system?

For the part of notification when someone loggs in your system, you could try to put a little script in a /etc/profile.d script. Using notify-send (part of the libnotify-bin package) you could try this :

/etc/profile.d/notify_log.sh

notify-send -t 3000 "User logged in" `whoami`

and then, every time someone will log in your system you will be notified.

EDIT: So, it doesn't work well :( If you configured a mail server on your machine, you can use the mail command instead of notify-send.

But according to the post here, the better solution would be a pam_exec script.


We do it by creating a file /etc/profile.d/notify.sh with the following content:

#!/bin/sh

sender="[email protected]"
recepient="[email protected]"
subject="Privileged Account logon used"
message="`env`"
    echo "$message" | mail -s "$subject" -r "$sender" -Smtp=mail.example.com "$recepient"

Assuming mailx is installed.