LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How we can put last login like root in Redhat? (https://www.linuxquestions.org/questions/linux-newbie-8/how-we-can-put-last-login-like-root-in-redhat-83021/)

sneak_nakata 08-18-2003 02:17 AM

How we can put last login like root in Redhat?
 
Ok.. my problem is like this..

I want to know how to set the last login like root at the user account. An example when we successfully login, we got like this...

root@192.168.0.2's password:
Last login: Mon Aug 18 14:54:43 2003 from 192.168.0.1

I hope u'all care to show how to do it.. thanks! :)

jdruin 08-18-2003 09:19 AM

Not sure what you are trying to do. Perhaps reword the question? What are you trying to accomplish? Here is some info on where that last login statement comes from.

In var/log/lastlog (a data file), there is an entry for each user on the system that contains the data about when the last login occured (if ever).

In /var/log/wtmp shows a complete list, in order, of all the users trying to log in and out plus reboots. THis is also a data file.

You can use 'lastlog' to view the contents of the var/log/lastlog and 'last' to view the contents of /var/log/wtmp

sneak_nakata 08-18-2003 02:05 PM

I mean like this, Firstly we login to redhat using putty program

username : root
password : blabalabla..

after that, the root account will display

root@192.168.0.2's password:
Last login: Mon Aug 18 14:54:43 2003 from 192.168.0.1

I want it display above information to my user account once i log in with user account, my user account is "babyboy"
so i want my user account can display the last login automaticly after i login with babyboy..

is it my question clear? hope it will clear u.. thanks..

jdruin 08-18-2003 02:26 PM

Okay. I think I see what you need. I think you can put this in your .bashrc for babyboy if you just want to see who logged in before you did:

last -d -f /var/log/wtmp -n 2

This will display 2 lines, the first will be about (babyboy) since he is the last login and the second line will be whoever logged in just before babyboy.

You could also do this:

lastlog -u root

to see when the last time root logged in.


All times are GMT -5. The time now is 02:19 AM.