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 often work on one of available to me Linux/HP-UX servers (let's say it is server1) and then do ssh server2 ((let's say it is server2)) and start working on another Linux/HP-UX server. Then I can connect another server ((let's say it is server3) and start working on it. While working on server3 how to get in command line information from what server I came from?

So on server3 I want to get information that I came from server2 and on server2 I want to get information that I came from server1? What is a command or utility for it?

share|improve this question

migrated from serverfault.com Nov 20 '13 at 16:23

This question came from our site for system and network administrators.

Try who, w, finger, or any of the tools that lists where the current users came from. – MadHatter Nov 20 '13 at 8:36
By the way how to show any research efforts? I mean I had done some search on the Internet using this sentence but found nothing useful. Is it OK just to mention that one had done some search on the Internet or it is not enough? – Sergei Kurenkov Nov 20 '13 at 9:29
I see on Meta that downvoting on the basis of showing any research efforts is little bit controversial for some people. As for this question putting How to find from what computer I connected to a current server in Google does not give anything about who on the first page. – Sergei Kurenkov Nov 20 '13 at 9:44
Personally, I don't find "it wasn't on the first page on google" to be enough research. Half an hour's searching and reading, that's a bit more like it, and by then you should have found something to tell us about, even if it's not exactly what you wanted. Seriously, it's just a downvote; absorb it, live with it, move on. – MadHatter Nov 20 '13 at 10:08
up vote 3 down vote accepted

At least for Linux, who <arg> <arg> will display the host you connected from.

$ who hates java
error    pts/3        2013-11-20 08:35 (underground)

The HP/UX man pages indicate the same is true for that operating system. As it should be; I've been using this for decades on a variety of Unixes...

share|improve this answer
Nice - I just had my own Kojak moment, typing "who loves ya" to test it. – MadHatter Nov 20 '13 at 9:14

who , whoami and last come to mind but no HPUX athand to test

share|improve this answer
Just to notice: who am i, not whoami – Sergei Kurenkov Nov 20 '13 at 12:03

Besides using who am i:

On Linux (RHEL 6.3)/HP-UX 11.31 ssh sets upon a successful connection several environment variables (ssh client environment variables)

SSH_CONNECTION shows the address of the client, the outgoing port on the client, the address of the server and the incoming port on the server

This is an example:

SSH_CONNECTION=' 36673 22'

So it is possible to get this environment variable and then nslookup to get information about a host from the connection was done.

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.