In our college we practice python on ssh. This command prints all the computers ( processes ) logged in.

ps -A | grep bash

I was wondering how to obtain my process ID for that session.

Recommended Answers

All 4 Replies

You may be able to combine the output of w or who - both list the TTY and connection - with the output of ps (which shows the TTY) to figure out which bash process is yours.

EDIT: Looks like bash has a built-in variable for just this purpose: $$ contains the current process ID.

Try "ps -aef" | grep bash | grep yourid"

Is there any way to get the IP of user( machine ) and corresponding Process ID, without admin rights.

To get the ip of the machine (there may be multiple) you can use ifconfig. Sometimes that wont reside in your $PATH so you will need to provide an absolute path with the name like: /usr/sbin/ifconfg

What do you want the process ID of? I gave you the answer above for the currently running process ($$). Is there another process you are interested in?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.