1

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

2 Answers 2

2

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.

3
  • 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, 2013 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, 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
    – zecrazytux
    Jan 17, 2013 at 15:24
5

last -10 will show last 10 logins.

Take a look over man last

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .