How to identify User Machine name?

Hi Experts,

We 4 to 5 people are using same UNIX(Solaris) login for our testing purpose. Also we are doing some modifications to existing scripts.

Is it possible to know the each user machine (IP address or machine name) who are using the same login to modify the scripts. So that we can easily identify who are modified what?

Please help me.

Ganapati.
Mysore.

check the w command. it will tell you from which IP address users have logged in

Certain compiled versions of 'w' can disable the display of 'from column' as NULL

Best would be use and parse the /etc/utmp structure

Thanks much Yogesh.

'w' is partially solved my problem. Also 'who' will give the machine IP address, which is more easier to identfy the user who are logged in.

But my two more doubts are:

  1. How to idetify from which IP address, the files get altered.
  2. How to get the previous history to identify who are logged in at what time and when they have logged out.

Any help will definitely use ful to enhance my UNIX knowledge.

Much Regards,
Ganapati.

You might want to have a look at lsof. I don't know if it is installed by default on Solaris but I'm pretty sure you could find a package for it:

From man page :

Lsof revision 4.77 lists information about files opened by processes for the following UNIX dialects:

An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path.

lsof | grep TCP output example :

firefox-b 5046 snerge 55u IPv4 170429 TCP 192.168.1.105:60473->wx-in-f19.google.com:https (ESTABLISHED)
firefox-b 5046 snerge 61u IPv4 170444 TCP 192.168.1.105:32840->od-in-f104.google.com:www (ESTABLISHED)
firefox-b 5046 snerge 63u IPv4 170450 TCP 192.168.1.105:32841->od-in-f104.google.com:www (ESTABLISHED)

Thanks for your help.
But sorry Im not getting it clearly.

I Need some more easy steps. Please.

With Regards,
Ganapati. :confused:

Try this...

Assuming that the <file_name> is an open file used by a process.

who | grep $(lsof <file_name> | sed -n '2,$p'| awk '{ print $3}'|uniq)

Hi Jacoden,

this command is giving some error.
[/opt/tuxedo/test]set -x

[/opt/tuxedo/test]touch testfile1.txt
+ touch testfile1.txt

[/opt/tuxedo/test]who | grep $(lsof <testfile1.txt> | sed -n '2,$p'| awk '{ print $3}'|uniq)
+ who

ksh: syntax error at line 1 : `|' unexpected

Pls suggest me.

  • Ganapati.

lsof testfile1.txt

matrixmadan,

tried ur suggestion and got the below error:

[/opt/tuxedo/lokesha]who | grep $(lsof testfile1.txt| sed -n '2,$p'| awk '{ print $3}'|uniq)
ksh: lsof: not found
Usage: grep -hblcnsviw pattern file . . .

can u pls explain what is "lsof" ? which seems to be not installed for me!!! :o

Cheers~~
Ganapati.

Seems lsof is not installed for you.

If installed should be available in /usr/sbin/lsof

lsof - this would display files opened by processes

how to instal it?

any idea matrixmadan.

  • :confused: Mysore Ganapati

you can download from
http://www.sunfreeware.com/

and install