Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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      21:12    2.00s  0.04s  0.04s -bash
share|improve this answer
Is the procps package available in Unix (specifically Solaris)? – omar 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 – omar Nov 10 '11 at 0:44
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
This flag doesn't exist on my SuSe system either. – n0pe Nov 10 '11 at 3:44
CentOS 6.5 doesn't have that option either. – aggregate1166877 Apr 29 '15 at 13:20

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


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.