Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know the process id of current bash session? [duplicate]

I'm on a linux server and admin user. There're many admin users using this machine at the same time. So under current bash command line, how to know the current process id of the bash process I'm using?

Thanks!

like image 368
Hind Forsum Avatar asked Jan 22 '17 04:01

Hind Forsum


People also ask

How do I find running process ID?

Task Manager can be opened in a number of ways, but the simplest is to select Ctrl+Alt+Delete, and then select Task Manager. In Windows, first click More details to expand the information displayed. From the Processes tab, select Details to see the process ID listed in the PID column. Click on any column name to sort.

How get PID details in Linux?

In this quick article, we've explored how to get the name and the command line of a given PID in the Linux command line. The ps -p <PID> command is pretty straightforward to get the process information of a PID. Alternatively, we can also access the special /proc/PID directory to retrieve process information.

Which variable gives the PID of the current process in shell?

There is a special variable called "$" and "$BASHPID" which stores the process ID of the current shell. Go ahead and run the below command to see what is the process ID of your current shell.


1 Answers

You can use echo $$ to get the PID of the current Bash shell you are using.

like image 67
v_sukt Avatar answered Oct 04 '22 02:10

v_sukt