Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This seems like such a basic security feature I'm surprised it's not already standard.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can use the last command to show that last logins, maybe put it in /etc/profile.d:

last $USER

However, I would be careful outputting any more to the screen than necessary, because some automated login bits (non-interactive) don't like extra output and fail. Maybe put in /etc/bashrc and detect if it is a login shell with shopt -q login_shell, and only run if it is.

share|improve this answer
1  
.bashrc is sourced for both login and interactive shells wheras .bash_profile (or .profile for other shells) is sourced only for login shells. –  zecrazytux Jan 17 '13 at 13:54
1  
Yes, but if you want it for all users, rather than modifying every .bashrc or .bash_profile on the system, then you would modify /etc/profile, /etc/bashrc, or drop a file in /etc/profile.d. –  lsd Jan 17 '13 at 14:18
    
right, so replace the dots by /etc/ in my previous comment ;) "Maybe put in /etc/bashrc and detect if it is a login shell with shopt -q login_shell, and only run if it is." => better use /etc/profile –  zecrazytux Jan 17 '13 at 15:24

last -10 will show last 10 logins.

Take a look over man last

share|improve this answer

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.