This seems like such a basic security feature I'm surprised it's not already standard.
2 Answers
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.
-
1.bashrc is sourced for both login and interactive shells wheras .bash_profile (or .profile for other shells) is sourced only for login shells. Jan 17, 2013 at 13:54
-
1Yes, 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.– lsdJan 17, 2013 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 Jan 17, 2013 at 15:24