10

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?

  • 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
13

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
  • Is the procps package available in Unix (specifically Solaris)? – omar Nov 10 '11 at 19:21
4

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

  • 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
  • 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. – n0pe Nov 10 '11 at 3:44
  • CentOS 6.5 doesn't have that option either. – aggregate1166877 Apr 29 '15 at 13:20
  • no --ips option on arch too – Neel Basu Dec 23 '18 at 20:14
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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