I want to fetch user's login time and login date, is there any command in Unix providing User's login date and User's login time ? this problem i want to perform in Shell-script where username is accepting from the end-user and after checking the availability of user, i would like to fetch that user's login time and login date in different variable and then display using 'echo' command.
For past logins:
Also, the command
who lists current logins.
If you're looking for the date of the user's last login, some systems provide it directly, for example
lastlog -u "$USER_NAME" on Linux or
lastlogin "$USER_NAME" on FreeBSD. It's also available in the output of
finger, but not in an easy-to-parse form. In any case, it's available in the output of
last (on many unix variants,
last -n 1 "$USER_NAME" shows the last login; otherwise you can do
last "$USER_NAME" | head -n 1). Note that last login may not correspond to the last logout (e.g. a user remained connected from one origin for a long time and made a quick network login recently).