• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

accessing an unix account

how can i find the last "n" ip's that had accessed  an unix account by just knowing the account without its password.

P.S. n is a given number
0
Clauditza
Asked:
Clauditza
1 Solution
 
yokelCommented:
Try just typing "last". Usually gives a list of logins and logouts, and which hostname, or IP address they came from.
It gets the information from the /var/adm/wtmpx file.
0
 
rajeshp_69Commented:
Hello Clauditza,

Well my colleague yokel has told u the command that u can use to get the result. I am sending u a shell script which displays the ip address of last n logins for a particular account.

The shell script is as follows:

#!/bin/sh

if [ $# -ne 2 ]
then
   echo "\n\nUsage : last_ip <user_id> <no_of_logins>\n"
   exit
fi

last | grep $1 | head -$2


You can always improve it further. This is just a simple script. It uses command line arguement. To invoke the command just type (i am assuming the name of this script file is last_ip):

last_ip clauditza 5

The o/p will be as you had wished.

Good luck!! Let me know if this is ok or u want something else.

Rajesh
0
 
ClauditzaAuthor Commented:
tnx a lot for the script...yeah...i could say this is exactly what i have wanted to find out.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now