?
Solved

accessing an unix account

Posted on 2003-03-17
3
Medium Priority
?
266 Views
Last Modified: 2010-04-21
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
Comment
Question by:Clauditza
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:yokel
ID: 8150828
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
 
LVL 2

Accepted Solution

by:
rajeshp_69 earned 80 total points
ID: 8166816
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
 

Author Comment

by:Clauditza
ID: 8173340
tnx a lot for the script...yeah...i could say this is exactly what i have wanted to find out.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question