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.

I know the who command showing me all logged in users. But I want to somehow informed when someone but me loggs into my system. Any applet? Would also be nice if the applet shows the number of distinct users logged in, meaning having a login shell and established ssh connection.

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
Good idea, but no need to make it executable and no need to have a shebang, because files in /etc/profile.d/ are sourced. Only login shells (virtual terminals and ssh login) and some GUI login execute profile initialization. –  enzotib Jan 4 '12 at 11:57
    
@enzotib : thanks for the tips, I corrected my answer :) –  Cédric Julien Jan 4 '12 at 12:41
    
Ok, I've tried but without no luck so far. The reason is, that one user cannot notify another easily. Therefore some environment variables have to be set, see: g-loaded.eu/2007/11/18/…. So far I've some executable which does the stuff but not when I login!?! If I just source /etc/profile.d/notify_log.sh after login via ssh, the notification is send. I guess it is not executed properly after login. I observed /var/log/auth.log without luck. Any help? –  math Jan 4 '12 at 13:35
    
I found the reason: I use ZSH and /etc/zsh/zprofile is empty it should be supposed to source /etc/profile which in turn should source /etc/profile.d/*.sh, but does nothing at all! >-(.. I will source this explicitly then and check all other installed shells, since I don't know which login shells are used by all LDAP users.. Anyway thanks. –  math Jan 4 '12 at 13:50
    
@brubelsabs : oups, I edited my answer with other solutions –  Cédric Julien Jan 4 '12 at 13:50
show 3 more comments

Your Answer

 
discard

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.