accessing an unix account

Posted on 2003-03-17
Medium Priority
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
Question by:Clauditza
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

Expert Comment

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.

Accepted Solution

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:


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

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.


Author Comment

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

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