Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I can see the names of other users on the remote machine with the who command... I'd also like know the IP address of those users...

I was trying with the commands /sbin/ifconfing and netstat but I could not get positive results...

I need this solution compatible both with Linux and Unix...

Is there a command with that utility? Do I need to write a script or use a kind of pipes?

share|improve this question
4  
Just to be clear, who doesn't tell you about users on the same network, just users logged in to the same machine as you. –  jw013 Nov 10 '11 at 4:39
    
When I log in a distant machine, who gives me my origin machine name on both linux and solaris (last field, between parenthesis, when logged in locally from X I get the X display). Getting the IP from that should be easy (nslookup, host) –  AProgrammer Nov 10 '11 at 9:12

3 Answers 3

up vote 7 down vote accepted

Try the w command, part of the procps package.

$ w
 21:12:09 up 6 days,  7:42,  1 user,  load average: 0.27, 1.08, 1.64
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
h3xx     pts/11   192.168.1.3      21:12    2.00s  0.04s  0.04s -bash
share|improve this answer
    
Is the procps package available in Unix (specifically Solaris)? –  user12287 Nov 10 '11 at 19:21
    
@user12287 - I don't see why not; there exists a POSIX-compliant /proc structure, it should work, I think. –  amphetamachine Nov 10 '11 at 21:43

The who manpage on my Debian Linux system shows there's an --ips option to display IPs instead of hostnames.

share|improve this answer
    
I'll try that option when I'll back to the Solaris network lab. In my Xubuntu system doesn't show the IP address –  user12287 Nov 10 '11 at 0:44
4  
I don't have this flag on Gentoo either; it looks like it was added by Debian in 5.96-3 as part of bug 363126 –  Michael Mrozek Nov 10 '11 at 1:51
1  
This flag doesn't exist on my SuSe system either. –  MaxMackie Nov 10 '11 at 3:44

who is the command I use, but it is not 100% reliable. The resulting names are from the PTR record for the IP address. There may or may not be a matching A record for the name.

Data from ps and netstat can be integrated if you have root privileges. Otherwise you can only make educated guesses which connection belongs to which process.

There are other tools which can be used, but I haven't found any programs that have consistent parameters and output across UNIX/Linux flavors.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.