17

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!

Hind Forsum
  • 9,717
  • 13
  • 63
  • 119
  • 6
    `echo $$` or `echo $BASHPID`? See `man bash` for the difference. – dramzy Jan 22 '17 at 04:10
  • 3
    Thanks @dramzy. I found $BASHPID indeed useful, as it "`differs from $$ under certain circumstances, such as subshells that do not require bash to be re-initialized`". – Noam Manos Aug 06 '20 at 14:31

1 Answers1

38

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

Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
v_sukt
  • 1,384
  • 1
  • 10
  • 21